Jump to content

[SOLVED] Complex looping structure dies at variable iterations


doggee7

Recommended Posts

Hello all,

I have a looping structure that in super simplified format looks like this:

 

for( "while theres results from mysql query" ) {

   

    for( "every day in the pst six months" ) {

       

          "Several other complex child loops, involving variable assignment, if-else and sql calls"

 

    }

 

}

 

The problem is, when i run this script with any more than three results from the original query, the whole page fails.  After setting a counter within several of the loops, i've determined that the script dies at different iterations of the "for every day in the past six months" loop.  I've checked the possibility of both timeout restrictions, and php memory limits, and i seem to be well within the boundaries of both.  I am all out of ideas.  Other than the possibilty of php getting lost in a sea of thousands of if's and then's i can't figure out how to solve this problem.  If the script had errors, it should die at the same iteration everytime.  Can anyone help me out??

It's never very efficient to put a query inside of a loop that is iterating through related query results. A correct JOIN query between the related data will probably reduce the time it takes to about one second and will simplify the code as well.

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.