I have a lot of checkboxes to process in each page of my site. My intention is to store all the check items in the list in irrespective of which page it has been checked.
<?php
session_start();
$category_id=$_GET['cat_id'];
$subcat_id=$_GET['sub_id'];
$page_num=$_GET['page_num'];
$i = 0;
foreach($_POST['id'] as $checkbox){
$_SESSION[$i] = $checkbox;
$i++;
}
echo "<pre>";
print_r($_SESSION);
echo "</pre>\n";
echo '
<table width="400" border="1">
<form id="myForm" method="<?php $_SERVER["PHP_SELF"];?>" >
<tr>
<th width="41" scope="col">Select</th>
<th width="259" scope="col">Name</th>
<th width="32" scope="col">QTY</th>
</tr>
<div class="section" id="content">
';
if($result) {
if(mysql_num_rows($result)>0) {
$i=1;
while ($row = mysql_fetch_array($result))
{
$item_id = $row["item_id"];
$cat_id = $row["cat_id"];
$sub_id = $row["sub_id"];
$item_name = $row["item_name"];
//$type = $row["types"];
echo "
<tr>
<td align='center'><input type='checkbox' name='$item_id' value='$item_name' /></td>
<td> $item_name </td>
<td align='center'><input type='text' name='qty' size='4'/></td>
</tr>
";$i++;
}
echo'</div> <input type="submit" value="submit"/></form></table> ';
}
else {
echo" The second id statement defaunkt"; }
}?>
Few more details :
1. the page URL are something like this : http://www.blahblah.com/something.php?cat_id=10 or http://www.blahblah.com/something.php?cat_id=13. Please notice that only cat_id changes which in turn brings items from database under that category.
- Once user returns to the page the where he has selected a checkbox, that same checkbox should be shown as selected or checked.
Please help!! Racking my brains for 3 days trying to find this specific solution. Most tutorials have failed me.
Thank you soo much.