mike12255 Posted February 18, 2009 Share Posted February 18, 2009 Im creating a forum were 10 posts are showen per page, and at the moment im trying to take the number of posts and dirive how many pages should be shown. So i created this formula. 2(y-5) =y+(y-10) were y is equal to the total number of pages. so: 2(10-5) = 10+(10-10) 2(5) = 10 + 0 10 = 10 2(20-5) = 20+(20-10) 2(15) = 20+10 30=30 2(30-5) = 30+(30-10) 2(25) = 30+(20) 50 = 50 So the i expanded and simplified that equation: 2(y-5) = y+(y-10) 2y-10 = 2y -10y 2y-10= -8y -10 = -8y -2y -10 = -10y -10*-10 =y 100=y and in the end afteri finishe simplifying i forgot how i was using this equation and i got lost in my own math. Dont say this isnt related to php please because thisis the math that my code is going to run (the final equation) anyway anyone know what i was thinking when i did this? Y = the number of pages but I dont know howi figured out how to get the number of pages from the number of posts. Link to comment https://forums.phpfreaks.com/topic/145667-solved-my-math-confuses-me/ Share on other sites More sharing options...
DarkWater Posted February 18, 2009 Share Posted February 18, 2009 Err... Let p be the number of posts, let m be the number of posts per page and let y be the number of pages. [tex]y = \frac{p}{m}[/tex] You'd need to use ceil() in PHP on the result to get the actual number of full pages though. Link to comment https://forums.phpfreaks.com/topic/145667-solved-my-math-confuses-me/#findComment-764745 Share on other sites More sharing options...
mike12255 Posted February 18, 2009 Author Share Posted February 18, 2009 your math looks a lot better...is celi away of getting rid of decimals? Link to comment https://forums.phpfreaks.com/topic/145667-solved-my-math-confuses-me/#findComment-764751 Share on other sites More sharing options...
genericnumber1 Posted February 18, 2009 Share Posted February 18, 2009 ceil() rounds up, floor() rounds down, round() rounds with typical rounding rules Link to comment https://forums.phpfreaks.com/topic/145667-solved-my-math-confuses-me/#findComment-764884 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.