iPixel Posted June 2, 2011 Share Posted June 2, 2011 Long story short i'm paginating database results. So pages = results / res-per-page-limit but 28 / 10 will be 2.8 should i use round() or ceil()? Quote Link to comment Share on other sites More sharing options...
WebStyles Posted June 2, 2011 Share Posted June 2, 2011 In my opinion you should always use ceil. This is mainly because you just want to know if there's gonna be another page or not, even if that page just has one result. if the value was 2,1 and you used round(), the result would be 2 pages, but in fact you need 3 to display all the results. Hope this made sense. Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 2, 2011 Share Posted June 2, 2011 Well, think about it for a moment. If you have 10 records per page and you have 21 records, the result would be: 21 / 10 = 2.1 So, if you have 21 records would you need tow pages (i.e. round()] or would you need three pages [i.e. ceil()]? Quote Link to comment Share on other sites More sharing options...
iPixel Posted June 2, 2011 Author Share Posted June 2, 2011 Perfect sense, thank you! 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.