I have several columns in each row stored with a user's information. I have put a checkbox at the end of each row and a Delete button at the at the bottom of the table. How can I check a box and simply delete the whole row from the database? Possibly check multiple boxes and delete them all? I have looked up tutorials on this but never had any luck.
sfrider0 6 Junior Poster
Recommended Answers
Jump to PostIf you are going to use karuppasamy's example, I would make sure you add some protection, check that the values passed are actually numbers. Otherwise you may find that your database is open to attack.
Also, JavaScript is overkill here, no point using it when the same can be …
Jump to PostXan's example should work (except for a few syntax errors).
if ( is_array( $_POST['foo'] ) ) { //you should use post for security foreach( $_POST['foo'] as $id ) { if ( is_numeric( $id ) ) { mysql_query("DELETE FROM `table` WHERE `id` = {$id}") or die(mysql_error()); } } …
All 7 Replies
ds2r 0 Light Poster
karuppasamy -1 Newbie Poster
sfrider0 6 Junior Poster
Will Gresham 81 Master Poster
sfrider0 6 Junior Poster
somedude3488 228 Nearly a Posting Virtuoso
karuppasamy -1 Newbie Poster
nav33n commented: Please check the date before bumping and replying to an old dead thread. -1
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.