Hi,
I have a store and I wanted to display a sold out graphic when the stock level reaches zero.
If I put this code in each table cell it works just fine (adjusting the product_model for each) I get the graphic when the stock level is 0
<?php $query = " SELECT products_quantity FROM products WHERE products_model='JLP.1A.4' ";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result))
if ( $row['products_quantity'] == 0 )
{echo '<img src="images/SoldOut.jpg" width="32" height="32" alt="" >' ;} ?>
Now I attempted to put most of that in a function so the function
<?php
function checkStockLevel()
{
$query = " SELECT products_quantity FROM products WHERE $stockModel ";
$result = mysql_query($query);
while(list($products_quantity)= mysql_fetch_row($result))
if ( $products_quantity == 0 )
{
echo '<img src="images/SoldOut.jpg" width="32" height="32" alt="" >' ;
}
}
?>
and then in each table cell I put this (adjusting each product) and calling the function
<?php echo checkStockLevel ($stockModel='JLP.1A.4') ;?>
However when I do that I get this error instead of the graphic -
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/wan/public_html/junior2.html on line 47
line 47 is the line -
while($row = mysql_fetch_assoc($result))
Thanks in advance for any ideas,
jim