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 have a PHP script that displays data from mysql in a nice tabular format. I have included a submit button along with each row. Now what i want is that on clicking a button corresponding to a row should delete the entire row from the page as well from the MySql database. This is my code so far....Please help.
Instead of using a "submit" button, just use either a button or a hyperlink that calls a "delete" script with the key field of the record you want to delete. It could look like this (where I'm assuming that you have a primary key column named "ID"):
As hawleyjr pointed out, this isn't a very good user interface, but it should illustrate the way the fundamental process works. In a practical situation, you would probably want to use Ajax to confirm the process to the user and refresh the screen with a new query result.
thanks hawleyjr & califdon...well i'l definitely try this out and get back soon again...actually i am a student and this work is for my final term project work. and i will be coming back with more queries again...
security could be beaten by disabiling cookies and javascript -- but management didn't quite see what was wrong with that. Instead, they told the client to NEVER copy paste content from other pages
pritam79 wrote:How can i make my application a standalone one which wont have any dependencies?.
califdon wrote:Instead of using a "submit" button, just use either a button or a hyperlink that calls a "delete" script with the key field of the record you want to delete. It could look like this (where I'm assuming that you have a primary key column named "ID"):
As hawleyjr pointed out, this isn't a very good user interface, but it should illustrate the way the fundamental process works. In a practical situation, you would probably want to use Ajax to confirm the process to the user and refresh the screen with a new query result.
Otherwise, create a form for every row, and insert a hidden element containing the id of the row you want to delete. Otherwise, both techniques are identical.
I'd just like to say that although this code was only intended to suggest an approach to solving the problem, it's a very bad idea to use hyperlinks for anything destructive. You should always use POST requests to do something destructive since many web related tools will try to browse those links (e.g. the google bot or certain browser plugins you may have installed) and wreak havoc in your system.