javascript - removing row from database through delete button in a php table -
I'm trying to create a little control panel so that I add and remove rows in the database. I have already worked by linking it, but there is some problem with me being removed.
The page shows each row in the table and there is also a deleted button behind it.
This is the code I have
This is the code that creates the table:
". $ Line ['uname']." & Lt; / Td> "; echo" & lt; Td> "$ line ['pass']." & Lt; / Td> "; echo" & lt; Td> ['E-mail']. "& Lt; / td> Echo "& lt; td & gt; & lt; input type = 'submit' class = 'button' id =". $ Line ['id']. "Value = 'del' & gt; & lt; / td & gt;"; Echo "& lt; / tr & gt;";} echo "& lt; / tbody & gt; & lt; / table & gt;";? & Gt;
Here is the AJAX code:
& lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {$ ('. Button'). Click (function () {var btnID = $ (this) .id; jQuery.ajax ({type: "POST", url: " $ ('# Succes') {$ ('# error'). Remove (); $ ('# succes'). HTML ("Hate account veravijer.") And other {$ ('# error') empty (); $ ('#Error'). Html ("Er is in fat octetenden.
Probier opnieuw!")}}}}}}};}); & Lt; / script & gt; ;
and here is delete.php:
$ Id = mysql_real_escape_string ($ _ POST ['id']); $ delete = "xxx` Go from `.xx` where` xxx`.` id` = '$ id' "; $ del = mysql_query (delete $); if ($ del) {echo" succes ";} and {echo" error "; // Close Connection mysql_close ();}? Gt;
When I press the Delete button, I get the SIS message, but the row has not been removed from my database.
I am trying to fix it, but I can not seem to work it
DB Connect Code)
My advice to you is never to delete from your database.
Instead, add a boolean variable to your table, which is set to '1' by default, and whenever you want to "delete" a row, set your bool to '0' Please.
When you ask your table to show on your page, WHERE boolVariable = '1' query
For security reasons, this is the best way, and make sure that "debug"
source:
Comments
Post a Comment