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!
$sql = "SELECT * FROM dbproducts";
$result = mysql_query($sql) or die(mysql_error());
while (true)
{
$row = mysql_fetch_assoc($result);
if ($row == false) break;
$val = $row['product'];
$val1 = $_POST[$val];
if ($val1 > '0')
{
print("<input type='hidden' name='$val' value='$val1'>");
}
}
The checkbox value is set to 0 on each product by default and the script I wrote tests whether the checkbox value is more than 0. Instead of displaying the product, it displays nothing therefore the value is not passing 0.
Of course this isn't the best way since the compiler tests both the while and the if conditions instead of just the while one, and it is time consuming. Ok, you must show him this, but don't make he think he's doing all wrong.