Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello

Please help me.
I am trying to get my php to get the checked list box state in a loop.
Please tell me what I have done wrong.

PHP
mysql_connect($mysql_host,$mysql_user,$mysql_password);
if(mysql_select_db($mysql_database))
{
	{
		$query2 = "SELECT * FROM PrefSkinRange";
		$result2=mysql_query($query2);
		$count2=mysql_numrows($result2);
		$code2;
		for($i = 0 ; $i < $count2 ; $i++)
		{
			$str=mysql_result($result2,$i,"PrefSkinRange");
			$nstr = str_replace(" ","",$str);
			$nstr = strtolower($nstr);
			$ssr = "NO";
			if(isset($_POST['$nstr']) && $_POST['$nstr'] == 'OK')
			{
				$ssr = "YES";
			}
			$code2 = "$code2 <input type='checkbox' name='$nstr' value='OK'><FONT COLOR='FFFFFF'>$nstr:$ssr</font><BR>";
		}
		$ssr = "NO";
		if(isset($_POST['ONE']) && $_POST['ONE'] == 'OK')
		{
			$ssr = "YES";
		}
		echo "<form action='page6.php' method='post'>
		<input type='checkbox' name='ONE' value='OK'><FONT COLOR='FFFFFF'>ONE:$ssr</font><br>
		<input type='hidden' value='1' name='run' />
		$code2
		<input type='submit' value='TEST' />";
	}
}
else
{
	echo "ERROR DATABASE";
}


All help is greatly appreciated.

Thanks
Posted
Comments
Uday P.Singh 10-Mar-12 13:14pm    
are you getting any error or what?
M.R. Inc 10-Mar-12 13:16pm    
Hello

No error.

Just never receives that the check box was checked.
M.R. Inc 10-Mar-12 13:29pm    
Any idea?

Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900