MySQL Forums
Forum List  »  PHP

Re: How to delete rows of a table through PHP?
Posted by: Barry Galbraith
Date: August 06, 2013 10:36PM

You need to have the primary key field of each database row written to the link that the red x will call.
The red x will have a link something like
<a href="delete.php?id=212"><img src="red_x.gif"></a>
where the 212 is the id of the database row.

Then the file delete.php handles $GET['id'], which if this red x was clicked would equal "212".
this results in a query along the lines of
"DELETE FROM my_table WHERE id_field=212"
and the row disappears.

Now, if you want the row to just disappear from the page, without a page refresh, then you'll need to have some javascript attched to the onclick handler for your "Red x" to call the delete.php file with the row id, and remove the row from the display if the delete action returns "success".
Google "ajax" and "jquery" for more info.

Good luck,
Barry.

Options: ReplyQuote


Subject
Written By
Posted
Re: How to delete rows of a table through PHP?
August 06, 2013 10:36PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.