do while's

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

do while's

Post by fariquzeli »

I have a huge table that takes data from for different mysql tables and i want it to keep printing out the data while there is data in the 4 tables (the 4 tables will all have the exact same number of rows)

I assumed i could get it to print the info from all the tables while there was info in one, but then it only prints the data from that one table, and the data from the other tables just repeats the first row.

Code: Select all

while ($row_generalInfo = mysql_fetch_assoc($generalInfo));
now i want it to have multiple operators, but by using the "+" i was getting an operand error how should i code that?

should i do it like this:

Code: Select all

while ($row_generalInfo = mysql_fetch_assoc($generalInfo) || $row_curriculum = mysql_fetch_assoc($curriculum) || $row_products = mysql_fetch_assoc($products)); [/cdoe]

or should i use the word AND, or is there a way to do it with the "+" sign?
User avatar
RandomEngy
Forum Contributor
Posts: 173
Joined: Wed Jun 26, 2002 3:24 pm
Contact:

Post by RandomEngy »

What you have looks good, but it depends on where you want it to stop. If you want it to stop when one of the parts runs out of results, use && . If you want it to stop when all of the parts run out of results, use || .
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

I'm not entirely sure what you are trying to do - if you are trying to combine information from four different tables into one wouldn't it just be easier to have one SQL query which does this and therefore one result set?

Mac
Post Reply