benvalmont Posted February 19, 2008 Share Posted February 19, 2008 Hi guys im New to this PHP thingy; i just want a help about the Simple way i can make PHP Paging by numbers Thanks Link to comment https://forums.phpfreaks.com/topic/91840-php-paging-the-simple-way/ Share on other sites More sharing options...
timmy0320 Posted February 19, 2008 Share Posted February 19, 2008 What do you mean exactly by paging by numbers? What is it going to be used for? If you mean page.php?value= then you can do it two ways. I prefer the switch method Say you had index.php?id=1 and it was looking for the id number you would simply do: switch ($_GET['id']) { case '1': default: echo "this is page 1"; break; case '2: echo "this is page 2"; break; } The default: is for setting that case as the default page. For more info check out http://www.php.net/switch Hope this helps some. Link to comment https://forums.phpfreaks.com/topic/91840-php-paging-the-simple-way/#findComment-470352 Share on other sites More sharing options...
benvalmont Posted February 19, 2008 Author Share Posted February 19, 2008 Well what i have in mind is : when i search my site it comes with the Result, 15 Results per page, and when the result is Display i want link on my results so i can visit the link the result is Displaying.. thanks hope im not Confusing u Link to comment https://forums.phpfreaks.com/topic/91840-php-paging-the-simple-way/#findComment-470357 Share on other sites More sharing options...
aschk Posted February 19, 2008 Share Posted February 19, 2008 You need to create a pager class (or script) that takes the total number of results, and the currnet page (if there is one) and gives you back the next page, previous page, and the cut of your results (i.e. from 20-30). You can take a look at Pear::Pager class which is part of the standard Pear build, and analyse what they've done. This should give you some ideas. Link to comment https://forums.phpfreaks.com/topic/91840-php-paging-the-simple-way/#findComment-470359 Share on other sites More sharing options...
Sulman Posted February 19, 2008 Share Posted February 19, 2008 Are your results being returned from a MySQL database? If so you can use the LIMIT clause. e.g. if 15 results returned and you have listed the first 10 you can use "SELECT * from table LIMIT 10, 15" on the next page. Link to comment https://forums.phpfreaks.com/topic/91840-php-paging-the-simple-way/#findComment-470363 Share on other sites More sharing options...
benvalmont Posted February 19, 2008 Author Share Posted February 19, 2008 Thanks Guys, So i want to know what Do i do to Display the number of Records in a Database... Thanks again Link to comment https://forums.phpfreaks.com/topic/91840-php-paging-the-simple-way/#findComment-470398 Share on other sites More sharing options...
timmy0320 Posted February 19, 2008 Share Posted February 19, 2008 Your question is not clear enough and you never stated what database system you're using. I know what you're asking you want a search page, displaying search results with X number of results per page. We get what you are trying to do but you aren't stating what you need help on exactly. How much of the PHP language do you know? Link to comment https://forums.phpfreaks.com/topic/91840-php-paging-the-simple-way/#findComment-470425 Share on other sites More sharing options...
redarrow Posted February 19, 2008 Share Posted February 19, 2008 Pagination http://www.sitepoint.com/article/perfect-php-pagination Link to comment https://forums.phpfreaks.com/topic/91840-php-paging-the-simple-way/#findComment-470430 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.