salman_ahad@yahoo.com 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 ?> Quote 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="" ? Quote 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 Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/179392-delete-empty-cells/#findComment-946649 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.