Jump to content

[SOLVED] Complex looping structure dies at variable iterations


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.