Alternative to Redirecting?

Discussion in 'PHP' started by Anim9or, Sep 30, 2010.

  1. #1
    Hello again, I have been working on a website since I began PHP about a year ago, and now I'm looking to clean it up a little and one of the things I'd like to fix was one of the first things I did and it's such an embarassing detail that I still don't know how to fix.

    Long story short, several webpages on my site require heavy, time consuming activities, particularly the mosaic maker, which is entirely php based. Most of these pages will crash if I make them do everything at once and will return an internal server error. To fix this, I break down each task into steps, for example it will only do one column at a time when making a mosaic, then it will redirect to the same page with a get variable with the column number+1 to work on next. Like this, it continues reloading the page until the task is done. This works well on smaller projects, but confuses people when they see their page refreshing every few minutes and sometimes return an error that says the page has redirected in a way that will be infinite. I am sure there is a better way to do this and I am willing to rewrite the process to find something more usual and efficient, but I still have not learned how to do this :( or what to google to find this type of solution. Does anyone know a way to keep a php looping until it finishes everything on one page? It has been driving me crazy!
     
    Anim9or, Sep 30, 2010 IP
  2. Narrator

    Narrator Active Member

    Messages:
    392
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    80
    #2
    It sounds like this could be done better by integrating ajax, that way the page wouldn't have to refresh. There's plenty of php ajax tutorials out there to get you started.

    Cheers!
     
    Last edited: Sep 30, 2010
    Narrator, Sep 30, 2010 IP
    Anim9or likes this.
  3. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #3
    i second to Narrator, ajax / jQuery can handle this one.
     
    bartolay13, Oct 1, 2010 IP
  4. Anim9or

    Anim9or Peon

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Funny, I was just reading an introduction to AJAX the other day. I think I could utilize it pretty well. Thanks :)
    Just because I've never used it before though, could someone give me a general idea of what to do? I'm not asking for the code or anything specific, I was just wodnering of doing something as simple as creating a request to use an external php script will actually do what I need in or I need to do something more complex to avoid the internal server error. Or would I just break it down into small files and have them execute consecutively.
     
    Anim9or, Oct 1, 2010 IP