Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PHP Execute - Small Help


Pelvis

Recommended Posts

Hello! all OsCommerce friends, I am a newbie in coding try to make a php script that do follow simple task: 

DELEETE from Table "supplier_product" all the rows from column "model" that have NULL values or are EMPTY
What I make wrong, here is my code

 

<?php   if(isset($_POST['submit'])){
$code = $_POST['niks_code1'];
}
?>
-------
<form name="niks_code1" action="<?php $delete_null="DELETE FROM `supplier_product` WHERE (`model` IS NULL OR `model` = '')"; ?>" method="POST">
<button type="submit" name="niks_code1" style="display:normal; color:green; font-size:11px; font-weight:bold;">Remove Null Records</button>
</form>

 

Link to comment
Share on other sites

Moderator, please move to PHP & MySQL area.

Can you do a MySQL query directly from a form action? Where is the connection to the database? I think you'll have to have your action be to run a routine that sets up and runs a MySQL query to do the deletion.

Link to comment
Share on other sites

Thanks for help!
This has done the Job
 

<?php if (isset($_GET['my_code'])) 
{
$remove_null="DELETE FROM `supplier_product` WHERE (`model` IS NULL OR `model` = '')";
tep_db_query($remove_null);
}
?>

<form action="<?=MY_FILE_NAME ?>" method="get">
  <input type="hidden" name="my_code" value="run">
  <input type="submit" value="Remove Null Records">
</form>

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...