So here is my problem. I have a 2 tables. One for the Product details and One for the Product quantity.
In the product details there is a field Status it should be available or Not Available. Then in the Product quantity table there is a qtyleft meaning the quantity available for the product. Now the problem is i put 0 on quantity on 4 products meaning no quantity left and it should echo "Item is out of stock". It works but on 1 item only. I can't figure this out because I analyze everything and i think there is no problem. Is this a bug or what?
Here is my code:
<?php
if (isset($_GET['id']))
{
include('config.php');
$id=$_GET['id'];
$result = mysql_query("SELECT * FROM athan_products WHERE product_id = $id");
while($row3 = mysql_fetch_array($result))
{
$resultq = mysql_query("SELECT * FROM inventory WHERE product_id LIKE '%".$id."%'");
//$resultq = mysql_query("SELECT * FROM inventory WHERE product_id LIKE =$id");
while($rows = mysql_fetch_array($resultq))
{
$qwerty=$rows['qtyleft'];
}
if ($qwerty !=0){
echo '<tr>';
//echo '<td>'.$row3['product_size_name'].'</td>';
echo '<td>'.$row3['price'].'</td>';
echo '<td>'.$row3['description'].'</td>';
echo '<td>'.'<input name="but" type="image" value="'.$row3['id'].'" src="images/button.png" onclick="return myFunction()" />'.'</td>';
echo '</tr>';
}
else
{
echo '<tr>';
//echo '<td>'.$row3['product_size_name'].'</td>';
echo '<td align="center">'.'<h2>'.'Item is out of stock!'.'</td>';
echo '</tr>';
//echo '<td>'.'<h1>'.'"not available"'.'</h1>'.'</td>';
}
}
}
?>