Sunday 15 May 2011

PHP: In forEach, stopping execution when a condition is reached, but continuing later -


After

Suppose i have something like this:

  $ count = 0; {$ CourseDetails as $ course_line} from {print} to & lt; foreach ($ course_line); TR & gt; & lt; TD & gt; {$ course_line ['class_code']} & lt; / td & gt; & lt; td & Gt; {$ course_line ['CLASS_NAME']} & lt; / TD> gt; & lt; td & gt; {$ course_line ['class_unit']} & lt; / td> & lt; td & gt; {$ Course_line ['class_description']}  gt; & lt; td & gt; {$ course_line ['class_instructors']} & lt; / td & gt; "; $ Count = $ count + 1 if ($ count = 10); $ Count = 0; // code which prevents script and "continue"? If the button pops up on the web page under the already outputed description // Press "Continue?" Button, to continue the script (jump back into the foreach loop)}   

I stopped trying to script and then finding a way to make a button Am "Continue?". If the customer presses the button, then I want to continue the script where it was left. Is there any work in PHP that allow this?

Short answer: No!

This is a workflow design issue, I would recommend to create a list of items to execute. Then to execute them (as they are successfully processed, marked them full), if any error is hit, then stop the execution and try the user's address. If the user wants to continue, then reload the page, and continue to execute those items which have not been completed from your initial list.

No comments:

Post a Comment