product base......| descrip'..| price
productA............| nice.......| £3.oo
----------------------------------------
product additive | mix ratio | quantity
productX............| 5:1........| 4
----------------------------------------
product base......| descrip'..| price
productA............| nicer......| £4.oo
---------------------------------------
product additive | mix ratio | quantity
productF............| 3:1........| 2
----------------------------------------
etc...
Here's the problem: The resulting rows for the 'product base' part are based on a query, say $query1, the resulting rows for the 'product additive' part is from another query, $query2.
In other words I need to perform $query1 which finds, say, where all the mix ratios=10:1, print the first resulting row, then perform $query2 which finds an additive product, print the resulting row, then loop through to find all the products where mix ratio=10:1 and then below each resulting row display its additive. I can't just have a link table saying that productX is always used with product additiveY, because that's not always the case.
Here's my code so far. However, it displays all the product bases, then below displays all the product additives (and, of course, I need the product additive to be displayed below each instance of the product base):
- Code: Select all
if ($app == 'BG' || $app == 'SES' || $app == 'VB')
{$query1 = "SELECT * FROM $table, $table1
WHERE $table.id = $table1.product_id
AND ty = 'o' AND APP LIKE '%$app%' ";}
else {$query1 = "SELECT *FROM $table , $table1
WHERE $table.id = $table1.product_id AND $table.ty != 'c'
AND et etc";}
$result = mysql_query ($query); if ($row = mysql_fetch_array($result))
{ echo ("These Products match your criteria:<BR>");
echo ("<table><tr><td width=70>product base</td>
<td width=70>description</td><td width=70>price</td></tr></table>");
do {
echo ("<table><tr>");
echo("<td width=70>{$row['product_base']}</a></td>");
echo ("<td width=\"70\">{$row['mix']}</td>");
echo ("<td width=\"70\">{$row['price']}</td>");
echo ("</tr></table>");
}
while($row = mysql_fetch_array($result));
}
else {
echo("Sorry, no matching additive was found");
}
// find appropriate additive - second query //
$result2 = mysql_query ("SELECT * FROM $table
WHERE ty ='c'
AND WL LIKE '%$wk%' AND MX LIKE '%$mix%'
ORDER BY whatever ");
if ($row = mysql_fetch_array($result2))
{
echo ("<table><tr><td width=70>product additive</td>
<td width=70>product additive</td></tr>");
do {
echo ("<table cellpadding=\"1\"><td width=\"110\" bgcolor=\"#CCCCCC\" class=tabletxtl>");
echo ("<b>{$row['prod']}</b>");
echo ("</td></table>");
}
while($row = mysql_fetch_array($result2));}
If you have read this far, do you know what I mean? I'm stumped. Any ideas?

