6
What happens in my PHP code is the following: I make a query in the database and with it a DO WHILE (while this query returns records), it displays some information on the screen (based on the query, of course). So far, everything is fine. However, I need now, within this DO WHILE, put another, to go through another query and 'printar' other values. I need this inside another WHILE DO because the new query will always be according to the ID generated in the first query, that is, different for each iteration. Tests in several ways but did not rotate or get error. How can I have a "while" and within this, after the "do", have another?
Ex:
do{
do{
while($consulta2 = mysql_fetch_assoc($dados2));
while($consulta = mysql_fetch_assoc($dados));
What your query of
$dados
returns? Add the queriessql
what you do.– user28595
Adds the entire code.
– Edilson
Good day friend , post here the codes of your 2 queries . One while inside another I particularly do not recommend . In case ,I believe that making a Join between the tables would be better.
– Henrique Felix
If I understand your doubt well you intend to use a while inside another to be able to query two distinct tables that have related id’s right? If so, I believe that the best alternative instead of using multiple whiles would be to use "Joins" directly in your SQL: What is the difference between INNER JOIN and OUTER JOIN? Good Luck!
– Fleuquer Lima
Iterate one query into another? Just ... don’t ... do ..... it ....
– gmsantos