Jump to content
Latest News: (loading..)
Sign in to follow this  
Pelvis

PHP Execute - Small Help

Recommended Posts

Posted (edited)

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>

 

Edited by Pelvis

Share this post


Link to post
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.


If you are running the "official" osC 2.3.4 or 2.3.4.1 download, your installation is obsolete! Get the latest community-supported responsive "Edge" release

Share this post


Link to post
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>

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×