Hello, i am quite new to php and i need some help in making my checkbox stay checked. I have been searching tutorials about checkboxes for hours but i still cant find one which fits my needs because none of them has a variable as a checkbox name. I will admit my friend helped me alot in the checkbox part but i still dont fully get it... would be great if someone was kind enough to explain them to me
Description
=======
Ok i am making a chemical printout.i have added a chemical list from the database and the idea is to print out the list of chemicals which i checked in the checkbox. The table currently is able to print out which ever checkbox i have ticked but the problem is if i click on refresh or submit button, the checkbox automatically unchecked it. this is my current checkbox $count=0(initially). ignore the sql connection and the search bar coding with it "SelectedChemicalsPrintingPage.php" is the other folder that i will be directed to after i clicked on submit. There, it will print out all the chemicals which i had checked.
<?php
error_reporting (0);
mysql_select_db("leslie", mysql_connect("localhost","root",""));
$result=mysql_query('select * from table2 WHERE Chemicals LIKE "%'.$_REQUEST['Search'].'%" '.$Controlled);
$count=0;
echo "<form action=SelectedChemicalsPrintingPage.php method=post>";
echo "
<table border='1'>
<tr>
<th>Select</th>
<th>Chemicals</th>
<th>Quantity</th>
<th>Location</th>
<th>Controlled</th>
</tr>
";
while($row = mysql_fetch_array($result))
{
echo "
<tr>
<td><input type=checkbox name=".$count." value=".$row[Chemicals]."></td>
<td>" . $row[Chemicals] . "</td>
<td>" . $row[Quantity] . "</td>
<td>" . $row[Location] . "</td>
<td>" . $row[Controlled] . "</td>
</tr>
";
if( isset($_POST[$count]) ) echo "checked='checked'"; <---i suppose this is placed wrongly?
$count++;
}
echo '</table>';
echo '
<input type=hidden name=counts value="'.$count.'">
<input type=submit name=submit >
</form>
';
?>