im new here and new in PHP too..
Just wondering how to make my own flexible loop just like in Wordpress... Note im not talking about wordpress.. I want to implement it on myown PHP application...
let's look back in WP, there is a code something like this:
while (have_post() : thepost())// .. bla bla...
echo the_title();
echo the_content();
endwhile; // this is just an ilustration
Could you figure out how have_post() or the_post() interact with database, so that they can be loop..
thanks..
WordPress uses global variables that these functions modify when iterating through the loop. e.g.:
I would definitely recommend using OOP style coding over what WordPress does, however. This will keep variables definied within an instance of an object instead of being globally accessible. e.g.:
Go to this problem again :D
finally I got the solution,
@Matt Huggins, i have made some revision to your code, and now it's work...
Many thanks... :)
the idea is to use global scope variables, and then the functions will modify those variables:
I hope that help.
You could implement the Iterator interface.