PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I recently started learning PHP on my own and started to use mysql and apache as well. I made a basic table in mysql and using some php code i displayed the table in a html table in a browser. Now I'd like to add a delete button beside each row and when clicked, it would delete that row. I am very new to this and I'm just practicing. Could anyone please help me? This is the code I have so far:
First, don't use mysql_ functions. Seriously. These functions have been deprecated and will be removed from the language. Especially if you're just starting, do yourself a favour and become familiar with PDO before bad habits become ingrained. Also, don't use the root account for MySQL. Or anything, really.
That said, if you're looking to create a single delete link, delete.php?id=foo will suffice. In your delete script, check for $_GET['id'], make sure it's a valid ID, and then pass that in to your DELETE FROM query. If you'd like to delete multiple entries with a single submission, create a form with a checkbox array containing the IDs and delete the selected IDs on post.