473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 1520
shouldn't mysql_free_result($displayResults); be outside the loop?
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: jason | last post by:
Access 2000: I have a customer-inventory table I need to loop through and compile a list of all the inventory items the customer is tracking. The problem I am finding is that a simple loop...
47
by: Mountain Bikn' Guy | last post by:
Take some standard code such as shown below. It simply loops to add up a series of terms and it produces the correct result. // sum numbers with a loop public int DoSumLooping(int iterations) {...
6
by: JP SIngh | last post by:
Hi All I run a query which gets data from two tables. I store in MainContracts Table ContractId InitiatedBy
32
by: Wenjie | last post by:
Hello, We had a code review with the argument of whether "i" is out of scope as illustrated below: for (int i=0; i<2004; i++) { doSomething(i); }
14
by: Crimsonwingz | last post by:
Need to calculate a sum based on a number of factors over a period of years. I can use formula ^x for some of it, but need totals to carry over in the sum and have only been able to do this thus...
52
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
5
by: marcsirois | last post by:
I have an SQL Query that looks like this. I simplified it for the purpose of this example, but it's still a runnable query SELECT TOP 1 FundedPositions.PositionNumber AS , (select top 1...
3
by: Akira | last post by:
I noticed that using foreach is much slower than using for-loop, so I want to change our current code from foreach to for-loop. But I can't figure out how. Could someone help me please? Current...
8
by: SaltyBoat | last post by:
Needing to import and parse data from a large PDF file into an Access 2002 table: I start by converted the PDF file to a html file. Then I read this html text file, line by line, into a table...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.