[email protected] Posted October 28, 2009 Share Posted October 28, 2009 I have a table "testtable" in MySQL col1 = id //primary key col2 = text <?php //test.php .. $result = mysql_query("SELECT * FROM testtable"); if($result) { //What code shall I write to delete empty text associated with any id ?> Link to comment https://forums.phpfreaks.com/topic/179392-delete-empty-cells/ Share on other sites More sharing options...
mikesta707 Posted October 28, 2009 Share Posted October 28, 2009 delete FROM testtable WHERE text="" ? Link to comment https://forums.phpfreaks.com/topic/179392-delete-empty-cells/#findComment-946571 Share on other sites More sharing options...
Mchl Posted October 28, 2009 Share Posted October 28, 2009 And if column allows for null values add OR text IS null `text` is MySQL's reserved word BTW, and should be avoided as identifier Link to comment https://forums.phpfreaks.com/topic/179392-delete-empty-cells/#findComment-946583 Share on other sites More sharing options...
PFMaBiSmAd Posted October 28, 2009 Share Posted October 28, 2009 And then, if you have not already done so, you need to add some validation logic to your form processing code to prevent rows having empty values from being inserted. Link to comment https://forums.phpfreaks.com/topic/179392-delete-empty-cells/#findComment-946649 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.