$query = "SELECT * FROM seats WHERE SeatStatus = 1";
$display = @mysql_query($query);
if ($display){
$disable = "disable";
}
<input name="ch1" type="checkbox" id="A1" value="" <?php echo $disable ?>/>;
how do i add “disable” inside the code…ive tried many time..but still didnt work..
Im new with php btw…Thanks..~
The main problem is that you are not checking if the query returned any results or an empty set. You are just checking whether the query is successful.
mysql_query()would return false only when the query is wrong. In your case the query is correct, so$display = mysql_query();will always evaluate to a non-false value.To solve this, you should check how many rows
mysql_query()returns usingmysql_num_rows(). So let’s rewrite your code.Hope that helps…
Peace…