Solved

help with pagination

Posted on 2008-10-30
12
280 Views
Last Modified: 2013-12-13
i have a few things in trying to do

1.
Code: [Select]
<?php echo "...<a href=\"".$_SERVER['PHP_SELF']."?page=message&id=$id&pagenum=$totalpages\"echo $totalpages</a>&nbsp;&nbsp;"; ?> im trying to make it so it shows the lastpage number...
Code: [Select]
<?php $numofpages = $rows / $page_rows;
    $totalpages = ceil($numofpages);?>but it wont echo it out :S



im trying to show my links like this

[1] 2 3 4 5 ...56 <= last page

but im not sure how to only echo upto 5 pages out?

my code is below
Code: [Select]

<?

    echo "<br>";

}

echo "<p>";
 
 

//// Find out the total number of pages depending on the limit set

    $numofpages = $rows / $page_rows;

    $totalpages = ceil($numofpages);

// Start links for pages

$maxpage = $totalpages == 0 ? 1 : $totalpages; // add this line

echo "<p align=center>Page $pagenum of $maxpage <br /> "; // change this
 

// Sets link for previous 25 and return to page 1

    if($pagenum != 1){

        $pageprev = ($pagenum - 1);

         echo "<a href=\"".$_SERVER['PHP_SELF']."?page=message&id=$id&pagenum=1\"><<</a>&nbsp;&nbsp;";

}
 
 

// Loop thru all the pages and echo out the links

    for($i = 1; $i <= $numofpages; $i++){

        if($i == $pagenum){

            echo "[".$i."] ";

        }else{

            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=message&id=$id&pagenum=$i\">$i</a> ";

        }

    }
 

// Check for straglers after the limit blocks

    if(($rows % $page_rows) != 0){

        if($i == $pagenum){

            echo "[".$i."] ";

        }else{

            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=message&id=$id&pagenum=$i\">$i</a> ";

        }

    }

// Print out the Next 25 and Goto Last page links

    if(($rows - ($page_rows * $pagenum)) > 0){

        $pagenext = $pagenum++;

     

          echo "...<a href=\"".$_SERVER['PHP_SELF']."?page=message&id=$id&pagenum=$totalpages\"echo $totalpages</a>&nbsp;&nbsp;";

    }else

echo "</p>";

?>

Open in new window

0
Comment
Question by:runnerjp
  • 6
  • 6
12 Comments
 
LVL 17

Expert Comment

by:cem_turk
Comment Utility
1 ) You are trying to use echo again without ending first echo command.
  echo "...<a href=\"".$_SERVER['PHP_SELF']."?page=message&id=$id&pagenum=$totalpages\"echo $totalpages</a>&nbsp;&nbsp;"
should be
  echo "...<a href=\"".$_SERVER['PHP_SELF']."?page=message&id=$id&pagenum=$totalpages\">$totalpages</a>&nbsp;&nbsp;" ;
0
 

Author Comment

by:runnerjp
Comment Utility
ahhh thanks :)

so how would i make it so...

it only shows 5 pages here

// Check for straglers after the limit blocks
    if(($rows % $page_rows) != 0){
        if($i == $pagenum){
            echo "[".$i."] ";
        }else{
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=message&id=$id&pagenum=$i\">$i</a> ";
        }
    }

and then

if (something todo with more then 5 pages)
{    
   echo "...<a href=\"".$_SERVER['PHP_SELF']."?page=message&id=$id&pagenum=$totalpages\">$totalpages</a>&nbsp;&nbsp;" ;
}
0
 
LVL 17

Accepted Solution

by:
cem_turk earned 500 total points
Comment Utility
well here is a new aproach, hope you like it. Following code will print 2 previous pages then current page then the next 2 pages and finally the last page, if there are less then 2 prev or 2 next pages it will act accordingly.

if($pagenum>2) { //set starting page number according to current page

$start=$pagenum-2;

}

else {

$start=1;

}

if($totalpages>$pagenum+2) { //set ending page number according to current page

$end=$pagenum+2;

}

else {

$end=$totalpages;

}
 

for($i=$start;$i<=$end;$i++) { //print the numbers

     if($i == $pagenum){

            echo "[".$i."] ";

        }else{

            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=message&id=$id&pagenum=$i\">$i</a> ";

        }

}

if ($totalpages>$end)

{  //create the last page link   

   echo "...<a href=\"".$_SERVER['PHP_SELF']."?page=message&id=$id&pagenum=$totalpages\">$totalpages</a>&nbsp;&nbsp;" ;

}

Open in new window

0
 

Author Comment

by:runnerjp
Comment Utility
it showed nothign all the time :S
0
 
LVL 17

Expert Comment

by:cem_turk
Comment Utility
can you check if $pagenum is set?  if it is null then it is possible to show nothing.
0
 

Author Comment

by:runnerjp
Comment Utility
ok i think something is wrong with my code itself lol

basicly i added urs and i got the [1]234 to work but when i clicked on anouther number it didnt show any links :S


<?php 
 

//if ok carry on viewing page 
 

//This checks to see if there is a page number. If not, it will set it to page 1 

if (!(isset($pagenum))) 

{ 

    $pagenum = 1; 

} 
 

//Here we count the number of results 

//Edit $data to be your query 

$forum = $_GET['forum']; 

$data = mysql_query("Select * from forumtutorial_posts where parentid='0' AND forum = '$forum' ORDER BY important, lastrepliedto") or 

    die(mysql_error()); 

$rows = mysql_num_rows($data); 
 

//This is the number of results displayed per page 

$page_rows = 2; 
 

//This tells us the page number of our last page 

$last = ceil($rows / $page_rows); 
 

//this makes sure the page number isn't below one, or more than our maximum pages 

if ($pagenum < 1) 

{ 

    $pagenum = 1; 

} elseif ($pagenum > $last) 

{ 

    $pagenum = $last; 

} 
 

//This sets the range to display in our query 

$max = 'limit ' . ($pagenum - 1) * $page_rows . ',' . $page_rows; 

//This is your query again, the same one... the only difference is we add $max into it 
 

{ 

?> 

<title>forum</title>

<table width="100%" class="loggedin">

                        <tr>

                            <td >

                                <div class="c1">

                                    <div align="center"><em>

                                      <script type='text/javascript'>

var date=new Date(); // Gets the full date!

var day=date.getHours(); // Gets the hours!
 

if(day<=11) {

document.write('Good Morning,'); // If it's before 12 PM then display this!

} else if(day<18){

document.write('Good Afternoon,'); // After 12 PM display this!

} else {

document.write('Good Evening,'); // After 6 PM display this!

}

    </script>

                                    You are logged in as <?php echo ucwords(strtolower($username)) ?>.Your ip address is <?php echo

                                    $_SERVER["REMOTE_ADDR"]; ?>; this is stored for security reasons.</em> </div>

                                </div>                            </td>

                        </tr>

</table>

<div align="center">

  <h3><strong><u>Welcome to the <?php echo $forum ?> board!</u></strong></h3>

</div>

<table width="99%" >

                        <tr>

                            <td width="84%" height="21" ><?php

$getusersonline="SELECT user_id,user FROM useronline 

   WHERE 

 file = 'http://www.runningprofiles.com/members/index.php?page=forum&forum=$forum' AND

  timestamp > " . (time() - 900) ; //grab from sql users on in last 15 minutes

$getusersonline2=mysql_query($getusersonline) or die("Could not get users");

$num=mysql_num_rows($getusersonline2);
 

echo "<b>There " . ($num != 1 ? "are" : "is") . " $num user" . ($num != 1 ? "s" : "") . " currently viewing the $forum board: </B>";
 

$tmp = array();

while($getusersonline3=mysql_fetch_array($getusersonline2))

{

  $tmp[] = "<A href='$getusersonline3[user]'>$getusersonline3[user]</a>";

}

echo implode(',',$tmp);

?>                          </td>

                            <td width="16%" align="right" ><A href='index.php?page=mainforums'><img src="http://www.runningprofiles.com/images/homeforum.gif" alt="home" border="0"  />	</a><A href='index.php?page=post&forum=<?php echo 

$forum; ?>'><img src="http://www.runningprofiles.com/images/new_post.gif" border="0"  /></a></td>

  </tr>

</table>

<table width="99%" class='forum'> 

  <tr> 

    <td><table class='maintable'> 
 

<tr height="30px"class='headline'><td><div align="center">Key</div></td> 

  <td><div align="center">Topic</div></td> 

  <td width=20%><div align="center">Topic Starter</div></td> 

<td width="5%"><div align="center">Replies</div></td>

<td width="20%"><div align="center">Last replied time</div></td>

</tr> 

<? 

//We need to add a Little variable that will automatically increase so that

//Each div (container) in the editforum.php script is unique:

$CONT_ID = 1;
 

    $getthreads = "Select * from forumtutorial_posts where parentid='0' and forum = '$forum' ORDER BY important ASC, lastrepliedto DESC $max"; 
 
 

    $getthreads2 = mysql_query($getthreads) or die("Could not get threads"); 
 

    while ($getthreads3 = mysql_fetch_array($getthreads2)) 

    { 
 

           $important = $getthreads3['important']; 

?> 

 <tr <?php if ($important == 1) 

        { 

            $class = "mainrow1"; 

        } 

        else 

        { 

            $class = "mainrow"; 

        } ?> class="<? echo $class ?>">

   <td width="4%" height="39" align="center" valign="middle"><?php 
 

$query1 = mysql_query("SELECT COUNT(postid) FROM forumtutorial_posts WHERE( postid= '$getthreads3[postid]' OR parentid = '$getthreads3[postid]' ) AND author='$username'");

$count = mysql_result($query1, 0,0);

if ($count != 0) 

{

      echo '<img src="http://www.runningprofiles.com/images/posted.jpg" />';

   }

   else

   {echo '<img src="http://www.runningprofiles.com/images/posted2.jpg" />';}

  

?></td> 

<td width="45%" valign="top"><div align="left"><a href='index.php?page=message&forum=<? echo 

$forum; ?>&id=<? echo 

$getthreads3[postid] ?>'><? echo 

$getthreads3[title] ?></a>   

   

   <?php 
 

            include 'editforum.php'; 

//Now increase it:

$CONT_ID++;

         

        ; ?> 

      <?php if ($getthreads3['forumlock'] == 

1) 

        { 

            echo ' <img src="http://www.runningprofiles.com/images/quick_lock.gif" alt="locked"/>'; 

        } 

        if ($getthreads3['important'] == 1) 

        { 

            echo '<img src="http://www.runningprofiles.com/images/sticky.gif" alt="sticky"/>'; 

        } ?>

</div></td> 

  <td align="left" valign="middle"><a href='/members/<? echo $getthreads3[author]; ?>'><? echo 

$getthreads3[author] ?></a></td> 

  <td align="center" valign="top"><? echo $getthreads3[numreplies] ?></td> 

  <td valign="top"><? $dbtime = $getthreads3['lastrepliedto']; 

         $dbtime=$getthreads3['showtime']; $time = date("F j, Y, g:i a", $dbtime); 
 
 

// Get current timestamp

$intTime = time();

// Calculate difference

$intDiff = $intTime - $dbtime;

 

// Check time

switch($intDiff)

{

      case ($intDiff < 60):

                echo "<strong>Less than a minute ago</strong>";

                break;

        case ($intDiff < 3600):

                echo "<strong>Less than an hour ago</strong>";

                break;

        case ($intDiff < 7200):

                echo "<strong>One hour ago</strong>";

				break;

        case ($intDiff < 10800):

                echo "<strong>Two hours ago</strong>";

				break;

		case ($intDiff < 86400):

                echo "<strong>Today</strong>";

				break;

		case ($intDiff < 172800):

                echo "<strong>Yesterday</strong>";

                break;

        default:

               echo $time;

}

?><br> 

  Last post by <b><A href='<?php echo $getthreads3[lastposter]?>'><? echo $getthreads3[lastposter]?></a><a href='index.php?page=message&forum=<? echo 

$forum; ?>&id=<? echo 

$getthreads3[postid] ?>&pagenum=last'> <img src="http://www.runningprofiles.com/images/last_posting.gif"  alt="last post" border="0" /></a></b></td>

  </tr> 

<? 

    } 

?> 

</table></td> 

  </tr> 

</table> 

<br> 
 
 

</a> 

<p> 

  <? 

    echo "<br>"; 

} 

echo "<p>"; 
 
 

//// Find out the total number of pages depending on the limit set

    $numofpages = $rows / $page_rows;

    $totalpages = ceil($numofpages);

// Start links for pages

$maxpage = $totalpages == 0 ? 1 : $totalpages; // add this line

echo "<p align=center>Page $pagenum of $maxpage <br /> "; // change this
 

// Sets link for previous 25 and return to page 1

    if($pagenum != 1){

        $pageprev = ($pagenum - 1);

         echo "<a href=\"".$_SERVER['PHP_SELF']."?page=message&id=$id&pagenum=1\"><<</a>&nbsp;&nbsp;";

}
 
 

// Loop thru all the pages and echo out the links

    for($i = 1; $i <= $numofpages; $i++){

        if($i == $pagenum){

            echo "[".$i."] ";

        }else{

            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=message&id=$id&pagenum=$i\">$i</a> ";

        }

    }
 

// Check for straglers after the limit blocks

    if(($rows % $page_rows) != 0){

        if($i == $pagenum){

            echo "[".$i."] ";

        }else{

            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=message&id=$id&pagenum=$i\">$i</a> ";

        }

    }

// Print out the Next 25 and Goto Last page links

    if(($rows - ($page_rows * $pagenum)) > 0){

        $pagenext = $pagenum++;

     

   echo "...<a href=\"".$_SERVER['PHP_SELF']."?page=message&id=$id&pagenum=$totalpages\">$totalpages</a>&nbsp;&nbsp;" ;

    }else

echo "</p>";

?>

Open in new window

0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 17

Expert Comment

by:cem_turk
Comment Utility
ok you need to send and get your necessary variables like $forum or pagenumber etc... and you need to filter results of the select based on the page number (you can use LIMIT on SQL query) for that. To pagination to work you need to get $pagenum value from querystring as follows
 
<?php

//if ok carry on viewing page
$pagenum=$_GET['pagenum'];  //get the pagenum from the querystring

//This checks to see if there is a page number. If not, it will set it to page 1
if (!(isset($pagenum)))
{
    $pagenum = 1;
}
 
0
 

Author Comment

by:runnerjp
Comment Utility
i added it and it still displays nothing :S
0
 
LVL 17

Expert Comment

by:cem_turk
Comment Utility
oh, right the variables for sql select are not set too. ok here is a more complete one.

<?php 

 

//if ok carry on viewing page 

 $pagenum=$_GET['pagenum'];

$forum=$_GET['forum'];

//This checks to see if there is a page number. If not, it will set it to page 1 

if (!(isset($pagenum))) 

{ 

    $pagenum = 1; 

} 

 

//Here we count the number of results 

//Edit $data to be your query 

$forum = $_GET['forum']; 

$data = mysql_query("Select * from forumtutorial_posts where parentid='0' AND forum = '$forum' ORDER BY important, lastrepliedto") or 

    die(mysql_error()); 

$rows = mysql_num_rows($data); 

 

//This is the number of results displayed per page 

$page_rows = 2; 

 

//This tells us the page number of our last page 

$last = ceil($rows / $page_rows); 

 

//this makes sure the page number isn't below one, or more than our maximum pages 

if ($pagenum < 1) 

{ 

    $pagenum = 1; 

} elseif ($pagenum > $last) 

{ 

    $pagenum = $last; 

} 

 

//This sets the range to display in our query 

$max = 'limit ' . ($pagenum - 1) * $page_rows . ',' . $page_rows; 

//This is your query again, the same one... the only difference is we add $max into it 

 

{ 

?> 

<title>forum</title>

<table width="100%" class="loggedin">

                        <tr>

                            <td >

                                <div class="c1">

                                    <div align="center"><em>

                                      <script type='text/javascript'>

var date=new Date(); // Gets the full date!

var day=date.getHours(); // Gets the hours!

 

if(day<=11) {

document.write('Good Morning,'); // If it's before 12 PM then display this!

} else if(day<18){

document.write('Good Afternoon,'); // After 12 PM display this!

} else {

document.write('Good Evening,'); // After 6 PM display this!

}

    </script>

                                    You are logged in as <?php echo ucwords(strtolower($username)) ?>.Your ip address is <?php echo

                                    $_SERVER["REMOTE_ADDR"]; ?>; this is stored for security reasons.</em> </div>

                                </div>                            </td>

                        </tr>

</table>

<div align="center">

  <h3><strong><u>Welcome to the <?php echo $forum ?> board!</u></strong></h3>

</div>

<table width="99%" >

                        <tr>

                            <td width="84%" height="21" ><?php

$getusersonline="SELECT user_id,user FROM useronline 

   WHERE 

 file = 'http://www.runningprofiles.com/members/index.php?page=forum&forum=$forum' AND

  timestamp > " . (time() - 900) ; //grab from sql users on in last 15 minutes

$getusersonline2=mysql_query($getusersonline) or die("Could not get users");

$num=mysql_num_rows($getusersonline2);

 

echo "<b>There " . ($num != 1 ? "are" : "is") . " $num user" . ($num != 1 ? "s" : "") . " currently viewing the $forum board: </B>";

 

$tmp = array();

while($getusersonline3=mysql_fetch_array($getusersonline2))

{

  $tmp[] = "<A href='$getusersonline3[user]'>$getusersonline3[user]</a>";

}

echo implode(',',$tmp);

?>                          </td>

                            <td width="16%" align="right" ><A href='index.php?page=mainforums'><img src="http://www.runningprofiles.com/images/homeforum.gif" alt="home" border="0"  />	</a><A href='index.php?page=post&forum=<?php echo 

$forum; ?>'><img src="http://www.runningprofiles.com/images/new_post.gif" border="0"  /></a></td>

  </tr>

</table>

<table width="99%" class='forum'> 

  <tr> 

    <td><table class='maintable'> 

 

<tr height="30px"class='headline'><td><div align="center">Key</div></td> 

  <td><div align="center">Topic</div></td> 

  <td width=20%><div align="center">Topic Starter</div></td> 

<td width="5%"><div align="center">Replies</div></td>

<td width="20%"><div align="center">Last replied time</div></td>

</tr> 

<? 

//We need to add a Little variable that will automatically increase so that

//Each div (container) in the editforum.php script is unique:

$CONT_ID = 1;

 

    $getthreads = "Select * from forumtutorial_posts where parentid='0' and forum = '$forum' ORDER BY important ASC, lastrepliedto DESC $max"; 

 

 

    $getthreads2 = mysql_query($getthreads) or die("Could not get threads"); 

 

    while ($getthreads3 = mysql_fetch_array($getthreads2)) 

    { 

 

           $important = $getthreads3['important']; 

?> 

 <tr <?php if ($important == 1) 

        { 

            $class = "mainrow1"; 

        } 

        else 

        { 

            $class = "mainrow"; 

        } ?> class="<? echo $class ?>">

   <td width="4%" height="39" align="center" valign="middle"><?php 

 

$query1 = mysql_query("SELECT COUNT(postid) FROM forumtutorial_posts WHERE( postid= '$getthreads3[postid]' OR parentid = '$getthreads3[postid]' ) AND author='$username'");

$count = mysql_result($query1, 0,0);

if ($count != 0) 

{

      echo '<img src="http://www.runningprofiles.com/images/posted.jpg" />';

   }

   else

   {echo '<img src="http://www.runningprofiles.com/images/posted2.jpg" />';}

  

?></td> 

<td width="45%" valign="top"><div align="left"><a href='index.php?page=message&forum=<? echo 

$forum; ?>&id=<? echo 

$getthreads3[postid] ?>'><? echo 

$getthreads3[title] ?></a>   

   

   <?php 

 

            include 'editforum.php'; 

//Now increase it:

$CONT_ID++;

         

        ; ?> 

      <?php if ($getthreads3['forumlock'] == 

1) 

        { 

            echo ' <img src="http://www.runningprofiles.com/images/quick_lock.gif" alt="locked"/>'; 

        } 

        if ($getthreads3['important'] == 1) 

        { 

            echo '<img src="http://www.runningprofiles.com/images/sticky.gif" alt="sticky"/>'; 

        } ?>

</div></td> 

  <td align="left" valign="middle"><a href='/members/<? echo $getthreads3[author]; ?>'><? echo 

$getthreads3[author] ?></a></td> 

  <td align="center" valign="top"><? echo $getthreads3[numreplies] ?></td> 

  <td valign="top"><? $dbtime = $getthreads3['lastrepliedto']; 

         $dbtime=$getthreads3['showtime']; $time = date("F j, Y, g:i a", $dbtime); 

 

 

// Get current timestamp

$intTime = time();

// Calculate difference

$intDiff = $intTime - $dbtime;

 

// Check time

switch($intDiff)

{

      case ($intDiff < 60):

                echo "<strong>Less than a minute ago</strong>";

                break;

        case ($intDiff < 3600):

                echo "<strong>Less than an hour ago</strong>";

                break;

        case ($intDiff < 7200):

                echo "<strong>One hour ago</strong>";

				break;

        case ($intDiff < 10800):

                echo "<strong>Two hours ago</strong>";

				break;

		case ($intDiff < 86400):

                echo "<strong>Today</strong>";

				break;

		case ($intDiff < 172800):

                echo "<strong>Yesterday</strong>";

                break;

        default:

               echo $time;

}

?><br> 

  Last post by <b><A href='<?php echo $getthreads3[lastposter]?>'><? echo $getthreads3[lastposter]?></a><a href='index.php?page=message&forum=<? echo 

$forum; ?>&id=<? echo 

$getthreads3[postid] ?>&pagenum=last'> <img src="http://www.runningprofiles.com/images/last_posting.gif"  alt="last post" border="0" /></a></b></td>

  </tr> 

<? 

    } 

?> 

</table></td> 

  </tr> 

</table> 

<br> 

 

 

</a> 

<p> 

  <? 

    echo "<br>"; 

} 

echo "<p>"; 

 

 

//// Find out the total number of pages depending on the limit set

    $numofpages = $rows / $page_rows;

    $totalpages = ceil($numofpages);

// Start links for pages

$maxpage = $totalpages == 0 ? 1 : $totalpages; // add this line

echo "<p align=center>Page $pagenum of $maxpage <br /> "; // change this

 

// Sets link for previous 25 and return to page 1

    if($pagenum != 1){

        $pageprev = ($pagenum - 1);

         echo "<a href=\"".$_SERVER['PHP_SELF']."?page=message&forum=$forum&id=$id&pagenum=1\"><<</a>&nbsp;&nbsp;";

}

 

 

// Loop thru all the pages and echo out the links

    for($i = 1; $i <= $numofpages; $i++){

        if($i == $pagenum){

            echo "[".$i."] ";

        }else{

            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=message&forum=$forum&id=$id&pagenum=$i\">$i</a> ";

        }

    }

 

// Check for straglers after the limit blocks

    if(($rows % $page_rows) != 0){

        if($i == $pagenum){

            echo "[".$i."] ";

        }else{

            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=message&forum=$forum&id=$id&pagenum=$i\">$i</a> ";

        }

    }

// Print out the Next 25 and Goto Last page links

    if(($rows - ($page_rows * $pagenum)) > 0){

        $pagenext = $pagenum++;

     

   echo "...<a href=\"".$_SERVER['PHP_SELF']."?page=message&forum=$forum&id=$id&pagenum=$totalpages\">$totalpages</a>&nbsp;&nbsp;" ;

    }else

echo "</p>";

?> 

Open in New Window Select All 

Open in new window

0
 

Author Comment

by:runnerjp
Comment Utility
ok i fixed it.. ur code provided didnt work but i got it too do so :)

back to sqare one with the page showing [1]234...34
  <?

echo "<br>";
 

// Find out the total number of pages depending on the limit set

    $numofpages = $rows / $page_rows;

    $totalpages = ceil($numofpages);

// Start links for pages

$maxpage = $totalpages == 0 ? 1 : $totalpages; // add this line

echo "<p align=center>Page $pagenum of $maxpage <br /> "; // change this
 

// Sets link for previous 25 and return to page 1

    if($pagenum != 1){

        $pageprev = ($pagenum - 1);

         echo "<a href=\"".$_SERVER['PHP_SELF']."?page=forum&forum=$forum&pagenum=1\"><<</a>&nbsp;&nbsp;";

         echo "<a href=\"".$_SERVER['PHP_SELF']."?page=forum&forum=$forum&pagenum=$pageprev\">PREV&nbsp;</a> ";

    }else{

        echo "PREV&nbsp;";

    }
 
 

// Loop thru all the pages and echo out the links

    for($i = 1; $i <= $numofpages; $i++){

        if($i == $pagenum){

            echo "[".$i."] ";

        }else{

            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=forum&forum=$forum&pagenum=$i\">$i</a> ";

        }

    }
 

// Check for straglers after the limit blocks

    if(($rows % $page_rows) != 0){

        if($i == $pagenum){

            echo "[".$i."] ";

        }else{

            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=forum&forum=$forum&pagenum=$i\">$i</a> ";

        }

    }

// Print out the Next 25 and Goto Last page links

    if(($rows - ($page_rows * $pagenum)) > 0){

        $pagenext = $pagenum++;

          echo "<a href=\"".$_SERVER['PHP_SELF']."?page=forum&forum=$forum&pagenum=$pagenext\">NEXT&nbsp;</a>&nbsp;&nbsp;";

          echo "<a href=\"".$_SERVER['PHP_SELF']."?page=forum&forum=$forum&pagenum=$totalpages\">>></a>&nbsp;&nbsp;";

    }else{

        echo("NEXT");

    }

echo "</p>"

Open in new window

0
 
LVL 17

Expert Comment

by:cem_turk
Comment Utility
glad we have solved it
0
 

Author Comment

by:runnerjp
Comment Utility
but what about the origonal question lol
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now