I have a table in PHP which displays the result of the MySQL query.
The database table item_em has the price details of the items that are available in hypermarkets available in the database table hypermarket_em.There are some items that aren't available in the hypermarket. Hence when i display the prices in the table I want those cells with no price as N/A.
So my problem is I tried a code myself to display message when database table field has no value.But it doesn't work and I don't get any error as well. Any ideas much appreciated. Thank you.
Here is my code
$res = mysql_query("SELECT h_id FROM hypermarket_em") or die(mysql_error());
echo"<tbody><tr>";
while($row = mysql_fetch_array( $res ))
{
$result = mysql_query("SELECT item_name FROM items_em WHERE h_id=".$row['h_id'])or die(mysql_error());
while($drop_4 = mysql_fetch_array( $result ))
{
echo"<th scope=row>".$drop_4['item_name']."</th>";
$rslt = mysql_query("SELECT price FROM items_em WHERE item_name='".$drop_4['item_name']."' and h_id=".$row['h_id'])or die(mysql_error());
if (mysql_num_rows($rslt) == 0)
echo"<td>N/A</td>";
while($drop = mysql_fetch_array( $rslt ))
{
echo"<td>".$drop['price']."</td>";
}
}
}
echo"</tr></tbody>";
size($res), if zero, means no result.