What im trying to do is order the information by farm_id and with each farm_id I want to be able to grab the last 10 results of the farms butterfat.
Unfortanly i get an error when it does the second loop. I've read on many forums where loops within loops are fine with php. but I keep getting this error.
$sqlk="SELECT * FROM `lanco_lab_quality`";
$resultsk=mysql_query($sqlk);
//Get the farm id's
while($datak=mysql_fetch_array($resultsk))
{
$f1=$datak['farm_id'];
echo "<br>";
echo $f1;
$count=1;
$sqlj="SELECT * FROM `lanco_lab_quality` WHERE farm_id='$f1' ORDER BY `lanco_lab_quality`.`id` DESC ";
$resultsj=mysql_query(sqlj);
//Now get the last 10 results of butter fat for that farm id.
while($count<=10 && $dataj=mysql_fetch_array($resultsj))
{
echo $dataj['butterfat'];
$count++;
}
}
Here is the result i get The number at the top is the value of the farm_id.
882
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /web/lanco/test.php on line 17