Hi,
I have the following code in page which works fine:
$sqlquery= ="MY QUERY 1";
$dataresult = mysql_query($sqlquery);
while ($datarow = mysql_fetch_array($dataresult )) {
$itemid= $datarow['itemid'];
$item= $datarow['item'];
echo "
<div id=\"reportlistitem\">
<div id=\"idclass\">$itemid</div>
<div id=\"itemclass\">$item</div>
</div>";
}
mysql_free_result($result);
What I want to be able to do is within the while statement, run another seleect query which selects multiple items from a different table but that is linked on the itemid field of the main query (above) and store those retrieved results into an array, and to then echo an additional <div> into my divs above displaying the contents of the array separated by commas.
So my guess is it would look something like this :
$sqlquery= ="MY QUERY 1";
$dataresult = mysql_query($sqlquery);
while ($datarow = mysql_fetch_array($dataresult )) {
$itemid= $datarow['itemid'];
$item= $datarow['item'];
echo "
<div id=\"reportlistitem\">
<div id=\"idclass\">$itemid</div>
<div id=\"itemclass\">$item</div>";
$sql= "MY QUERY 2 WHERE productid = $itemid";
$result = mysql_query($sql);
// store it in an array???
// display it in a DIV separated by commas??
echo "</div>";
}
mysql_free_result($result);
Any help will be greatly appreciated.