if checkbox is checked

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Brandensmith1
Forum Newbie
Posts: 9
Joined: Tue Sep 11, 2007 3:43 pm

if checkbox is checked

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply