I have a table that is retrieved from mysql. I put a checkbox in front of every row. If the delete button is clicked, checked rows will be delete. I have successfully implemented it by using checked[] as the name of every row. Because I wrote some JavaScript and I have to replace that array by a normal variable, and then I move that checked[] to a hidden type to try to keep track checked rows, but it fails. It stores all rows. So no matter what rows are checked or not, all rows will be deleted if delete button is clicked. I don't know how to make mark on checked row(s) in order to pass it/them to the next page.
I'm even not sure why checked[] in the checkbox type would be able to store checked rows and pass it/them to next page, but why it doesn't work in the hidden type.
How could I delete checked rows by using a normal variable (not an array)?
Help please.
echo "<form action=\"delete_confirm.php\" method=\"post\" name=\"book\" >";
echo "<tr> <td><input type=\"checkbox\" name=\"book_click_all\" onClick=\"checkAll()\"></td> <td>Course Name</td> <td>Book Title</td> <td>Edition</td> <td>Condition</td> <td>Other Information</td> <td>Date Posted</td> <td>Price</td></tr>";
$i = 0;
do {
$courseN = $myrow["courseName"];
$title = $myrow["title"]; $edition = $myrow["edition"]; $quality = $myrow["quality"];
$price = $myrow["price"]; $other = wordwrap($myrow["otherInfo"], 41, "\n", 1); $time = $myrow["shijian"];
$uniq_id = $myrow["uniq_id"];
//I put a checkbox in front of every table row
//I need replace checked[] by a normal variable (in order to work with my JavaScript function)
printf("<tr> <td class=\"navbar\"><input type=\"checkbox\" name=\"checked[]\" value=\"$uniq_id\"> </td> <td class=\"navbar\%s</td>
<td class=\"navbar\">%s </td><td class=\"navbar\"><a href=\"javascript:void(0);\">%d</a></td>
<td class=\"navbar\">%s</td> ", $courseN, $title, $edition, $quality);
echo nl2br(" <td class=\"navbar\">$other</td> ");
printf("<td >%s</td> <td class=\"navbar\">%f</td></tr>", $time, $price);
//this line only stores all rows' id
//echo "<input type=\"hidden\" name=\"checked[]\" value=\"$uniq_id\">";
$i++;
} while ($myrow = mysql_fetch_array($result));
echo "<input type=\"submit\" name=\"submit_del_book\" value=\"Delete selected book\" >";
echo "</form></tr> ";
echo "</table>";