I have the following script for adding, editing and deleting mysql in friends, and showing it on the index.php file Used to be. So here is my index.php file:
& lt; Script & gt; Function goDel () {var recslen = document.forms [0]. Length; Var checkbox = "" (i = 1; i gt; {var con = confirm ("Are you sure you want to delete"); If (con) {document.forms [0] .action = "delete.php? Recsno =" checkbox document.forms [0]. Submit ()}} and {warnings ("no record has been selected.")}} Select function () {// var formname = document.getElementById (formname); Var recslen = document.forms [0]. Length; If (document.forms [0] .topcheckbox.checked == true) {for (i = 1; i gt; & Lt; TR & gt; & Lt; Td> & Lt; Hour size = "1" node & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; Form action = "" method = "post" name = "" id = "" & gt; & Lt; Width of the table = "600" border = "1" align = "center" cellpadding = "2" cell area = "2" & gt; & Lt; TR & gt; & Lt; Td> & Lt; Input name = "top checkbox" type = "checkbox" class = "check" id = "top checkbox" onClick = "selectall ();" Value = "on" & gt; Select all & lt; / Td> & Lt; Td colspan = "3" align = "center" & gt; & Lt; A href = "form.php? Mode = addition" & gt; Add new branch & lt; / A & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td> & Lt; Strong & gt; & Lt; A href = "javascript: goDel ()" & gt; Remove & lt; / A & gt; & Lt; / Strong> & Lt; / Td> & Lt; Td> & Lt; Strong & gt; Branch name & lt; / Strong> & Lt; / Td> & Lt; Td> & Lt; Strong & gt; Small name & lt; / Strong> & Lt; / Td> & Lt; TD & gt; & Lt; Strong> Update & lt; / Strong> & Lt; / TD & gt; & Lt; / TR & gt; By & lt;? Included ("conn.php"); $ Sql = "Brand name by SOR, choose short name from branch name $ $; $ result = mysql_query ($ sql, $ connection) or die (mysql_error ()); while ($ line = mysql_fetch_array ($ result)) { ? & Gt; & lt; tr & gt; & lt; td & gt; & lt; input name = "& lt;? Echo $ row ['sn'] ;? & Gt; "Type =" checkbox "class =" check "& gt; & lt; / td> & lt; td & gt; & lt ;? echo per line ['branchname'];? & Gt; Lt; / td & gt; & lt; td & gt; & lt;? Echo per line ['short-n'];? & Gt; & lt; / td> gt; & lt; td & gt; & lt; ; A href = "& lt;? Echo "form.php? Sn =". $ Line ['sn']. "& Amp; mode = update";; & Gt; Updates & lt; / a & gt; & lt; / TD & gt; & lt; / tr & gt; k This is my delete.php file :
& lt ;? php included ("conn.php"); $ Recsno = $ _ receive ["recsno"]; $ data = trim ($ recsno); $ Ex = explosion {$ Id = trim ($ ex [$ i] for $ ($ "$"); $ size = sizeof ($ east); ($ i = 0; $ i & lt; $ size; $ i ++) ); $ Sql = "Remove from branch where sn = '$ id'"; $ result = mysql_query ($ sql, $ connection) or die (mysql_error ());} header ("location: index.php" );? & Gt; The problem is that When I check the 1 line and click Delete, it is removing all the rows, like I clicked on selecting all (which I did not do). Thank you in advance.
It looks like the query is not getting the value of $ id $ Id . Just get the id value $ id = $ _REQUEST ["SN"]; Then delete your query $ sql = "$ branch, where sn = '$ id'";
No comments:
Post a Comment