Jump to content

[SOLVED] Problem with a while loop


mark110384

Recommended Posts

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

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++;

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.