I've got some PHP code that doesn't seem to be working. It's basically a script to remove selected elements from a table.
First, here's the code:
$sql = "SELECT slide_id from usercontent where username = $_SESSION[username]";
$result = mysql_query($sql,$conn);
$num_rows = mysql_num_rows($result);
print "-=$num_rows=-<br>";
for($inc = 0; $inc < $num_rows; $inc++) {
$id = mysql_result($result,$inc,'slide_id');
$val = "remove".$id."";
print "Now checking to see if checkbox '$val' was checked.<br>";
if($_POST[$val] == "CHECKED") {
print "A slide is being removed removed <br>";
$sql = "DELETE from usercontent where username = $_SESSION[username] and slide_id = $id";
mysql_query($sql,$conn);
}
}
The problem, I think, lies in the fact that I can't get $num_rows to equal the number of rows in the result table. Anyone happen to know why this is?