while loop error
Posted: Sun Apr 13, 2008 12:51 am
I have a loop within a table, that display posted variables that have been checked. That works, but when i get another value from mysql, its hard to put that in a result as i am looping it.
what i am trying to do is this:
1. select a value from a table. 2. put in a variable. 3. display. 4. increment
5. select different value 6. put in variable etc.
I get a warning message:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:...conorder.php on line 45.
The table shows up and the other data displays correctly, its just the status. that shows a blank with the warning message
I havent been able to do the standard while loop as i am only intending to get one result, increment, then get another.
what i am trying to do is this:
1. select a value from a table. 2. put in a variable. 3. display. 4. increment
5. select different value 6. put in variable etc.
I get a warning message:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:...conorder.php on line 45.
The table shows up and the other data displays correctly, its just the status. that shows a blank with the warning message
I havent been able to do the standard while loop as i am only intending to get one result, increment, then get another.
Code: Select all
for ($i=0; $i<count($_POST['ticked']); $i++) {
$row_value = $_POST['ticked'][$i];
$result2 =mysql_query("SELECT status from branch_items
WHERE drug_id=".$_POST['ticked'][$row_value]."
AND branch_id=".$_POST[branch_id][$row_value]."");
$row = mysql_fetch_array( $result2 ); // LINE 45
echo "<tr><td>";
echo $_POST[drug_id][$row_value];
echo "</td><td>";
echo $_POST[branch_id][$row_value];
echo "</td><td>";
echo $row[status];
echo "</td></tr>";
}
echo "</table>";
}