Solved

help with pagination

Posted on 2008-10-30
12
289 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
12 Comments
 
LVL 17

Expert Comment

by:Cem Türk
ID: 22840123
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
ID: 22840267
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 Türk earned 500 total points
ID: 22840584
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:runnerjp
ID: 22840639
it showed nothign all the time :S
0
 
LVL 17

Expert Comment

by:Cem Türk
ID: 22840694
can you check if $pagenum is set?  if it is null then it is possible to show nothing.
0
 

Author Comment

by:runnerjp
ID: 22840806
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
 
LVL 17

Expert Comment

by:Cem Türk
ID: 22840899
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
ID: 22841111
i added it and it still displays nothing :S
0
 
LVL 17

Expert Comment

by:Cem Türk
ID: 22841164
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
ID: 22841310
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 Türk
ID: 22841414
glad we have solved it
0
 

Author Comment

by:runnerjp
ID: 22843372
but what about the origonal question lol
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

622 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