Page 1 of 1

if checkbox is checked

Posted: Wed Sep 12, 2007 7:13 pm
by Brandensmith1

Code: Select all

$query = "SELECT * FROM newsart GROUP BY count ORDER BY count desc";
	$result = mysql_query($query) or die(mysql_error());
	$green = "#CCFF99";
	$blue = "#99FFFF";
	$color = array($green, $blue);
	$g = "0"; 
	echo "<form method=\"post\" id=\"action\" name =\"form\" action=\"{$_SERVER['PHP_SELF']}\"><td>
	<table width=\"100%\">";
	while($row = mysql_fetch_array($result))
	{
echo "<tr bgcolor=\"$color[$g]\">
    <td>". $row['news_title'] ."</td>
    <td>". $row['name'] ."</td>
    <td>". $row['time'] ."</td>
    <td><input name=\"\" type=\"checkbox\" name=\"checked[". $row['count'] ."]\" value=\"". $row['count'] ."\"></td></tr>";
	$g++;
		if($g == "2")
		{
		$g = "0";
		}
	if($checked[$row['count']] == $row['count'])
	{
		echo "FINALLY!";
	}
	}
echo "<td><input type=\"submit\" value=\"Delete Selected\" /> </td></table></td></tr></table></form>";
This is what I have so far, I'm trying to make a script to delete the mysql rows of the values checked but I keep getting stuck on what seems to be the easy part, getting the script to recognize which boxes are selected. I'm not exactly sure why this is not working, i've also tried isset($checked[$row['count'])) with no luck either, what am I doing wrong?

Posted: Wed Sep 12, 2007 8:40 pm
by feyd
I'll guess $checked doesn't exist and you don't have E_NOTICE level errors messages being displayed. $_POST will have the data you are looking for.