I've got a table with a number of records. Now right now I choose them on a single page. But I wish to create a listing. Their email list would contain multiple (about 5-10) pages.
With this, must i use physical (page1.php page2.php page3.php) or virtual pages (page.php?number=1 page.php?number=2 page.php?number3)?
I am likely to rephrase your question during my answer after which answer my question...
That which you have is really a result set, which result set you want to have the ability to paginate the outcomes to ensure that you don't display all the products inside your results all at one time. You want to have the ability to display anywhere of results per page, but many likely something similar to five or ten results.
Okay, allows assume you have your result set that is loaded whenever you view
What for you to do however is just display a set fee of products from inside that result set.
I'll constitute an imaginary result set now.
$results = array( array( 'id' => 1, 'Apple'), array( 'id' => 2, 'Orange'), array( 'id' => 3, 'Banana'), array( 'id' => 4, 'Pinapple'), array( 'id' => 5, 'Kiwi'), array( 'id' => 6, 'Starberries'), array( 'id' => 7, 'Blackberries'), array( 'id' => 8, 'Melon'), array( 'id' => 9, 'Opal'), array( 'id' => 10, 'Zuchini'), array( 'id' => 11, 'Peach'), array( 'id' => 12, 'Pear'), array( 'id' => 13, 'Plum') );
Okay, now, this is often our imaginary result set. What you look for to complete, for the first page is retrieve just the first 5 products.
Then when someone visits
index.php, they'll only get (Apple, Orange, Blueberry, Pinapple and Kiwi).
This really is known as pagination. You may either paginate through results once you have retrieved them, or paginate before you will find the results by utilizing
limits in mySQL. Since you haven't stated you're using mySQL I've made the assumption you have all of your results already.
Now, for those who have a request that is available in like
You would then do that:
$page = $_GET['page']; $page ? is_numeric($page) && isset($page) ? $page : 1; $count = 5; $offset = $page == 1 ? 0 : (($page * $count) -1 ) - $count; // Slice now contains your results which you can use to foreach() through $slice = array_slice($results, $offset,$count);
Array (  => Array ( [id] => 1  => Apple )  => Array ( [id] => 2  => Orange )  => Array ( [id] => 3  => Banana )  => Array ( [id] => 4  => Pinapple )  => Array ( [id] => 5  => Kiwi ) )
Within this example, I've not done any actual blocking or any serious validation the $_GET page may be the correct format, but you need to get the concept.
You will find also lots of assets to create this simpler for you personally.
Personally, i am a massive fan of
Zend_Paginator that we use for those my pagination needs. See here Zend_Paginator
Also other assets:
Quick live example: Sample