Jump to content

Pagnation help


darkfreaks

Recommended Posts

it shows previous and next links but wont show 25 entries per page any ideas ???

 

<?php
  $limit          = 25;                
    $query_count    = "SELECT count(*) FROM vc_covenmessages WHERE catid='$catid'";     
    $result_count   = mysql_query($query_count);     
    $totalrows      = mysql_num_rows($result_count);
if(empty($page)){ 
        $page = 1; 
    } 
         

    $limitvalue = $page * $limit - ($limit);  
    $query  = "SELECT * FROM vc_covenmessages WHERE catid='$catid' ORDER BY `id` LIMIT $limitvalue,25";         
    $result = mysql_query($query) or die("Error: " . mysql_error());  

    if(mysql_num_rows($result) == 0){ 
        echo(""); 
    } 
  

while($row = mysql_fetch_array($result)){ }

if($page != 1){  
        $pageprev = $page--; 
         
        echo("<a href=\"board.php?catid=$catid&covid=$covid&page=$pageprev\">PREV".$limit."</a> ");  
    }else{ 
        echo("PREV".$limit." "); 
    } 

    $numofpages = $totalrows / $limit;  
     
    for($i = 1; $i <= $numofpages; $i++){ 
        if($i == $page){ 
            echo($i." "); 
        }else{ 
            echo("<a href=\"board.php?catid=$catid&covid=$covid&page=$i\">$i</a> "); 
        } 
    } 


    if(($totalrows % $limit) != 0){ 
        if($i == $page){ 
            echo($i." "); 
        }else{ 
            echo("<a href=\"board.php?catid=$catid&covid=$covid&page=$i\">$i</a> "); 
        } 
    } 

    if(($totalrows - ($limit * $page)) > 0){ 
        $pagenext = $page++; 
          
        echo("<a href=\"board.php?catid=$catid&covid=$covid&page=$pagenext\">NEXT".$limit."</a> ");  
    }else{ 
        echo("NEXT".$limit);  
    } 
     
    mysql_free_result($result); 



mysql_close();

include ('config.php');
$query4=trim(mysql_real_escape_string($query4));
$query4 = "SELECT * FROM vc_covenmessages WHERE catid='$catid' ORDER BY `id` LIMIT $limitvalue,25";
$result4 = mysql_query($query4) or die("Error: " . mysql_error());  

$numrows=mysql_num_rows($result4);

mysql_close();

$i=0;
while ($i < $num) {

$id = mysql_result($result4,$i,"id");
$username = mysql_result($result4,$i,"username");
$date = mysql_result($result4,$i,"date");
$message = mysql_result($result4,$i,"message");
$title = mysql_result($result4,$i,"title");

echo "<table width=\"60%\" cellpadding=\"0\" cellspacing=\"0\" class=\"cmessage\">
<tr valign='top'>
<td width=\"10%\" align=\"center\">
<a href=\"../profile/$username\"><br>$username</a><br>";
if ($status=="owner") {
echo "<input type='checkbox' name='id' value='$id'>";
};
if ($status=="admin") {
echo "<input type='checkbox' name='id' value='$id'>";
};
echo "</td>
<td width=\"50%\">
<table border=\"0\" width=\"100%\" class=\"titlebar\">
<tr><td align=\"left\"><B>$title</B></td><td align=\"right\">
$date
</td></tr>
</table>
$message
</td></tr>
</table>
";
$i++;
};?>

Link to comment
https://forums.phpfreaks.com/topic/90260-pagnation-help/
Share on other sites

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.