mark110384 Posted May 6, 2009 Share Posted May 6, 2009 Hey guys I'm having a problem with following loop, it essentially adds number to post replies with regard to the page number (using pagation) this is the code that I've got so far. $pageno = $_GET['pagenum']; $t=0; $post_no = 2; while ($t < $lastpage) { if ($pageno == $t){ $no_post = $post_no; } $post_no + 14; $t++; } this is what I want it to, but put it in a loop form if ($pageno == 1){ $no_post = 2; } else if ($pageno == 2){ $no_post = 16; } else if ($pageno == 3){ $no_post = 30; } else if ($pageno == 4){ $no_post = 44; } else if ($pageno == 5){ $no_post = 58; } and so on Thanks Link to comment https://forums.phpfreaks.com/topic/157084-solved-problem-with-a-while-loop/ Share on other sites More sharing options...
Ken2k7 Posted May 6, 2009 Share Posted May 6, 2009 First of all, how did you get those numbers for $no_post in your second block of code you have there? Link to comment https://forums.phpfreaks.com/topic/157084-solved-problem-with-a-while-loop/#findComment-827432 Share on other sites More sharing options...
kickstart Posted May 6, 2009 Share Posted May 6, 2009 Hi Try $post_no += 14; All the best Keith Link to comment https://forums.phpfreaks.com/topic/157084-solved-problem-with-a-while-loop/#findComment-827436 Share on other sites More sharing options...
mark110384 Posted May 6, 2009 Author Share Posted May 6, 2009 Hmmm that works somewhat Kickstart altough the 1 pages starts at 16 because it completes the first loop and adds it on the end. Link to comment https://forums.phpfreaks.com/topic/157084-solved-problem-with-a-while-loop/#findComment-827441 Share on other sites More sharing options...
Zhadus Posted May 6, 2009 Share Posted May 6, 2009 $no_post = (($pageno-1) * 14 + 2); That should do it. Link to comment https://forums.phpfreaks.com/topic/157084-solved-problem-with-a-while-loop/#findComment-827700 Share on other sites More sharing options...
mark110384 Posted May 7, 2009 Author Share Posted May 7, 2009 Excellent that works exactly how I wanted to do thanks guys. This is what I've got now $t=0; $post_no = 2; while ($t < $lastpage){ if ($pageno == $t){ $no_post = (($pageno-1) * 14 + 2); } else if ($pageno == 1){ $no_post = 2; } $t++; } Link to comment https://forums.phpfreaks.com/topic/157084-solved-problem-with-a-while-loop/#findComment-828293 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.