471,052 Members | 1,188 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,052 software developers and data experts.

Why while loop want query more than once?

Can someone explain why $displayResults will not query twice?

Scripts Objective:
to take a car's VIN retrieve the car info and display in nice rows

Issue with Script:
The while loop displays the first car with information but on the
second loop it will does not run the query for $displayResults all
though the $queryDisplayResults does change the car's Vehicle ID
Number

What am I not doing right?

db_connect();
while ($row1 = mysql_fetch_assoc($searchMatches))
{
$queryDisplayResults = "select userautoconnect.varAutoID,
carinfo.varYear, carinfo.varModel, carinfo.intMakeID,
carinfo.intPrice, carinfo.intMileage, autodescription.blobDescription
FROM carinfo, autodescription, userautoconnect WHERE ".
$row1['varAutoID']." = userautoconnect.varAutoID &&
userautoconnect.varAutoID = carinfo.varAutoID &&
userautoconnect.varAutoID = autodescription.varAutoID";
$displayResults = mysql_query($queryDisplayResults);

$displayMatchesX10 = mysql_num_rows($displayResults);

$row = mysql_fetch_assoc($displayResults);

//|||||||||||||||||||||||||||||||||||||||||Declare variable to print
Car maker ||||||||||||||||||||
$make = $row['intMakeID'];
$carMaker = getCarDefinition('definitioncar', 'intMakeID', $make);

echo " <A HREF= moreInfo.php?vin=".$row['varAutoID'].">";
echo "<tr VALIGN='top' bgcolor='#F5F5F7' style='cursor:hand';
onmouseOver= this.bgColor='#F0EF3C';
onmouseOut=this.bgColor='#F5F5F7'; >";
echo "<TD WIDTH='50px' HEIGHT= '30px' ALIGN='center'>";

echo "<P CLASS=searchResultsHeadings>Photo</P>";

echo "</TD>";
echo "<TD WIDTH='50px' ALIGN='center'>";

echo $row['varYear'];
echo "</TD>";

echo " <TD WIDTH='241px' ALIGN='center'>";
echo $carMaker."&nbsp;&nbsp;". $row['varModel'];
echo "</TD>";

echo "<TD WIDTH='60px' ALIGN='center'>";
echo $row['intMileage'];
echo "</TD>";

echo "<TD WIDTH='60px' ALIGN='center'>";
echo $row['intPrice'];

echo " </TD>";
echo "</TR></A> ";
mysql_free_result($displayResults);
}
Jul 20 '05 #1
1 1461
shouldn't mysql_free_result($displayResults); be outside the loop?
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

47 posts views Thread by Mountain Bikn' Guy | last post: by
6 posts views Thread by JP SIngh | last post: by
32 posts views Thread by Wenjie | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.