something like
$query = mysql_query("select id, name, batch_no from product");
while ($myrow=mysql_fetch_array($query))
{
$query_inv = mysql_query ("select number_in_stock, product_id, priority from inventory i where i.product_id=$query['id'] order by priority");
while ($myrow_inv=mysql_fetch_array($query_inv))
{
if ($myrow_inv['number_in_stock']>0)
{
<< some output >>
break;
}
}
}
priority would be a field where you could determine which product will backup another. If it finds product, it will break out of the loop. If product is out of stock, it will continue to the backup product.
🆒