kundan Posted January 6, 2009 Share Posted January 6, 2009 hello sir, I am displaying the records of mysql table in php and placed checkboxes to delete the selected items i have tried with the issue but in vain . could you please help me how to delete the selected records either with in the same page or by redirecting to another page Thanks in advance kundan Quote Link to comment https://forums.phpfreaks.com/topic/139657-deleting-selected-items/ Share on other sites More sharing options...
dreamwest Posted January 6, 2009 Share Posted January 6, 2009 This is mysql command: mysql_connect("localhost", "user", "pass") or die(mysql_error()); mysql_select_db("dbname") or die(mysql_error()); // Delete row where 15 from the "example" MySQL table mysql_query("DELETE FROM example WHERE anything='15'") or die(mysql_error()); echo "cool! all done"; Give me a table name and column names and ill adjust this for u Quote Link to comment https://forums.phpfreaks.com/topic/139657-deleting-selected-items/#findComment-730717 Share on other sites More sharing options...
dezkit Posted January 6, 2009 Share Posted January 6, 2009 <?php if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysql_query($sql); } ?> Source: http://phpeasystep.com/mysql/8.html Quote Link to comment https://forums.phpfreaks.com/topic/139657-deleting-selected-items/#findComment-730720 Share on other sites More sharing options...
kundan Posted January 6, 2009 Author Share Posted January 6, 2009 i hav followed with the give link and gone with the same example i created the same example table with the given database name and i was able to display the data but when i selected any record and clicked on delete button nothng was happenning and the checked checkboxes were made unchecked kundan Quote Link to comment https://forums.phpfreaks.com/topic/139657-deleting-selected-items/#findComment-730747 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.