php - Delete Rows from MySQL Database Using Checkboxes -


I am trying to delete a row from a table that is generated from a MySQL table. I took a look at these two questions: And I think both answers, but I am running into a problem. In each question, your checkbox is set in this way:

  & lt; Input name = "checkbox [  

and

  & lt; Input name = "checkbox []" type = "checkbox" value = "& lt ;? php echo $ row ['topic_id'] ;? & gt;" & gt;   

I am unable to use any of these in my code, because my table is generated in PHP, and using parentheses and quotations within my code (checkbox name Or value property, exact) throws a syntax error in magnificent, I am thinking that there is no alternative solution for this?

Here's a part of my table:

  & lt; Tbody & gt; & Lt ;? Php $ query = mysqli_query ($ db, "SELECT * SOISInventoryList WHERE numInStock = 0 item by itemName"); If (! $ Query) {echo "query could not be taken."; } And {while ($ line = mysqli_fetch_assoc ($ query)) {echo "; tr & gt;"; Echo "& lt; td class = 'strikeOut' & gt; . $ Line ['item name'] "& lt; / td & gt;"; Echo "& lt; td class = 'strikeOut' & gt; . $ Line ['numInStock'] "& lt; / td & gt;"; Echo "& lt; td class = 'strikeOut' & gt; . "$" $ Line ['valuePriceUnit'] "& lt; / td & gt;"; Echo "& lt; td class = 'delete' & gt; . "& Lt; input type = 'checkbox' name = 'delete' & gt;"; Echo "& lt; / tr & gt;"; }}? & Gt; & Lt; / Tbody & gt;   

Any kind of help or suggestions is appreciated. Your syntax problems (in a nutshell) come from the fact that you get the HTML of each line individually. Using echo command to print from For the type of work you are trying to do,

  & lt ;? Php while ($ row = mysqli_fetch_assoc ($ query)):? & Gt; & Lt; TR & gt; & Lt; Td square = 'strikeout' & gt; & Lt ;? = $ Row ['itemName']? & Gt; & Lt; / TD & gt; (Other TD) & lt; Td class = 'delete' & gt; & Lt; Input type = 'checkbox' name = 'delete [& lt ;? = $ Row ['id']? & Gt;] '& gt; & Lt; / Td> & Lt; / TR & gt; & Lt ;? Php timeline? & Gt;   

Printing in this way saves a lot of headaches (and feels great)!

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -