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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.