I'm attempting to delete a row from a table with data that is generated from a MySQL table. I took a look at both of these questions: How to delete rows of database results using checkbox and Deleting multiple rows using checkboxes, PHP and MySQL. I understand both of the answers, but I'm running into one problem. Each question has their checkbox setup like this:
<input name="checkbox[<?php echo $row['id']?>]"
and
<input name="checkbox[]" type="checkbox" value="<?php echo $row['topic_id'];?>">
I am unable to use either of these in my code, as my table is being generated in php, and using brackets and quotes within my code (the checkbox name or value property, to be exact) throws a syntax error in Sublime. I'm wondering if there is any workaround to this?
Here is a chunk of my table:
<tbody>
<?php
$query = mysqli_query($db, "SELECT * FROM SOISInventoryList WHERE numInStock = 0 ORDER BY itemName");
if(!$query){
echo "Could not grab query.";
}
else{
while($row = mysqli_fetch_assoc($query)){
echo "<tr>";
echo "<td class='strikeOut'>" . $row['itemName'] . "</td>";
echo "<td class='strikeOut'>" . $row['numInStock'] . "</td>";
echo "<td class='strikeOut'>" . "$" . $row['pricePerUnit'] . "</td>";
echo "<td class='delete'>" . "<input type='checkbox' name='delete'>";
echo "</tr>";
}
}
?>
</tbody>
Any kind of help or suggestions are appreciated.