php - No error message in this code but it doesn't delete the fields -


I do not have any error messages in this code but it does not delete data, however, the database has many records and all fields The names are correct.

  & lt ;? Php if ($ connect = mysqli_connect ('localhost', 'root', 'adminpass', 'flip')) {$ id = $ _GET ['id']; $ Sql ​​= "SELECT * threads ordered by ID DESC"; $ Query = mysqli_query ($ connect, $ sql); $ Num = mysqli_num_rows ($ query); }? & Gt; & Lt; Form action = "& lt ;? php echo $ _SERVER [" PHP_SELF "] ;? & gt;" Method = "post" & gt; & Lt; Table range = "1" width = "400" cellpadding = "0" cell area = "0" & ​​gt; & Lt; TR & gt; & Lt; TD & gt; # & Lt; / TD & gt; & Lt; TD & gt; Id & lt; / TD & gt; & Lt; TD & gt; Subject & lt; / TD & gt; & Lt; / TR & gt; & Lt ;? Php while ($ row = mysqli_fetch_array ($ query))? & Gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; Input type = "checkbox" name = "checkbox []" value = "& lt ;? php echo $ row ['id']? & Gt;" & Gt; & Lt; / Td> & Lt; Td> & Lt ;? Php echo $ row ['id']? & Gt; & Lt; / Td> & Lt; Td> & Lt ;? Php echo $ line ['subject']? & Gt; & Lt; / Td> & Lt; / TR & gt; & Lt ;? Php}? & Gt; & Lt; Input type = "submit" name = "delete" value = "delete" & gt; & Lt ;? Php if (remove isset ($)) {for ($ i = 0; $ i & lt; $ num; $ i ++) {$ del_id = $ check box [$ i]; $ Sql2 = "Remove from thread where id = '$ del_id'"; $ Query2 = mysqli_query ($ connect, $ sql2); } If ($ query2) {echo " 

What's the problem with it?

You can try this:

   gt; td & gt; id & lt; / td & gt; & lt; td & gt; subject & lt; / td & gt; & lt; / tr & gt; k & lt ;? $ Sql ​​= "SELECT * thread by ID DESC order"; $ Query = mysqli_query ($ connect, $ sql); $ Num = mysqli_num_rows ($ query); / * Submit the number of rows made through hidden input / echo "input type = 'hidden' name = 'hidden' value = '$ num' & gt;"; While ($ row = mysqli_fetch_array ($ query)) / / FETCH data * /? & Gt; & Lt; TR & gt; & Lt; Td> & Lt; Input type = "checkbox" name = "checkbox []" value = "& lt ;? php echo $ row ['id']? & Gt;" Gt; & Lt; / Td> & Lt; Td> & Lt ;? Php echo $ row ['id']? & Gt; & Lt; / Td> & Lt; Td> & Lt ;? Php echo $ line ['subject']? & Gt; & Lt; / Td> & Lt; / TR & gt; By & lt;? } / * When the interval is $ QUERY * /? & Gt; & Lt; Input type = "submit" name = "delete" value = "delete" & gt; & Lt ;? Php mysqli_close ($ connect); ? & Gt; & Lt; / Table & gt; & Lt; / Form & gt;  

Explain why your code does not work:

  • Your issued ($ delete) : Where did the $ delete variable come from?
  • Your for loop does not determine if the checkboxes have been submitted or not.
  • Your & lt; Meta & gt; Redirects it to for loop delete.php , so the reason is that you are not seeing any errors but I'm pretty sure That if you go to & lt; Meta & gt; Redirects, you will see some errors.
  • Even though it is working, you will not see the results after that because the removal query is after the data you bring.

Comments

Popular posts from this blog

Editing Python Class in Shell and SQLAlchemy -

import - Python ImportError: No module named wmi -

uislider - In a MATLAB GUI, how does one implement a continuously varying slider from a GUIDE created .m file? -