Pelvis Posted October 3, 2018 Share Posted October 3, 2018 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 More sharing options...
MrPhil Posted October 3, 2018 Share Posted October 3, 2018 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 More sharing options...
♥JcMagpie Posted October 3, 2018 Share Posted October 3, 2018 This shows how to do what your after. https://stackoverflow.com/questions/16438678/delete-contents-of-a-column-in-a-table-using-button Link to comment Share on other sites More sharing options...
Pelvis Posted October 3, 2018 Author Share Posted October 3, 2018 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.