Jump to content

While Loop in While Loop


ueon

Recommended Posts

I can identify an issue with your logic already, as:

 

while ($set2 = mysql_fetch_array($query))

 

mysql_fetch_array - Returns an array that corresponds to the fetched row and moves the internal data pointer ahead.

 

"moves the internal data pointer ahead" This means once the pointer moves to the end, it will not be looped again unless you reset the pointer like so:

 

mysql_data_seek($query);

 

I would like to see the rest of your code, though, as it looks like you may have more issues.

I can identify an issue with your logic already, as:

 

while ($set2 = mysql_fetch_array($query))

 

mysql_fetch_array - Returns an array that corresponds to the fetched row and moves the internal data pointer ahead.

 

"moves the internal data pointer ahead" This means once the pointer moves to the end, it will not be looped again unless you reset the pointer like so:

 

mysql_data_seek($query);

 

I would like to see the rest of your code, though, as it looks like you may have more issues.

 

The OP doesn't want to loop through the same results multiple times, and the loops use different MySQL results, so that shouldn't be an issue. It will be looped again if there are multiple results.

Essentially his logic would look like this:

 

Loop1 Output

  Loop2 Output

  Loop2 Output

  Loop2 Output

  Loop2 Output

 

Loop1 Output

Loop1 Output

Loop1 Output

Loop1 Output

 

Loop2 would execute once and then never do anything again. But as we have both said, we need the rest of the code to understand what you're doing.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.