Any PHP dudes fancy...
 

MegaSack DRAW - This year's winner is user - rgwb
We will be in touch

[Closed] Any PHP dudes fancy helping me out?

6 Posts
6 Users
0 Reactions
53 Views
Posts: 14057
Free Member
Topic starter
 

I've got a simple page that returns results from a mysql search but the results are not paginated yet.
I could figure out how to do this but it would take time as I'm not a very good at it, and I've got a potential client looking at it very very soon.
Anybody fancy chucking some code into it to paginate the results or pointing me at some code that I could use?


 
Posted : 20/10/2015 10:12 am
Posts: 0
Free Member
 

Pie chart anyone? 🙂

http://code.tutsplus.com/tutorials/how-to-paginate-data-with-php--net-2928


 
Posted : 20/10/2015 10:14 am
Posts: 14057
Free Member
Topic starter
 

Cheers Nemesis - seen that one, I'll take a look.


 
Posted : 20/10/2015 10:25 am
Posts: 0
Free Member
 

I'm not a php guy but it'll be pretty trivial to write your own version. You need three numbers: The number of results you want to show (n), the page number you're on (p) and the total number of results (t).

Use LIMIT n , n*(p-1) in the sql to get the results and use ceil(t/n) to get the total number of pages. Quick for x < numberOfPages loop to render the paging links and bob's your uncle.


 
Posted : 20/10/2015 10:26 am
Posts: 0
Free Member
 

nemesis - Member

Pie chart anyone?

SO reminded me of this (which may have been on STW years ago)
It has a few sweary bits – but it’s good

I Wish I Worked With This Man...He's Hilarious


 
Posted : 20/10/2015 10:57 am
Posts: 0
Free Member
 

PHP threads are never as funny as Photoshop threads... 🙁


 
Posted : 20/10/2015 10:59 am
 dazh
Posts: 13302
Full Member
 

I've got a potential client looking at it very very soon.

So you have a potential client but haven't yet figured out how to limit the number of results from an SQL query? Are you sure you're doing things in the right order? 😯


 
Posted : 20/10/2015 11:29 am