Page 1 of 1

do while's

Posted: Tue Jul 09, 2002 2:20 pm
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?

Posted: Tue Jul 09, 2002 2:27 pm
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 || .

Posted: Tue Jul 09, 2002 2:28 pm
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