Jump to content

Archived

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

techiefreak05

pagination problems PLEASE PLEASE HELP ME !!!!!!!

Recommended Posts

i have this code that displays all your friends bullletins.. and it limits 5 per page.. well its supposed to .. lets say there are 7 bulletins posted.. it shows all 7 on one page.. but says there are 2 pages of bulletins, like tis supposed to.. idk whats wrong.... you see anything?!?!?!??!!?


[code]<?php
$query="SELECT * FROM friends WHERE `username` = '$_SESSION[username]' AND `accepted` = 'yes'";
$result=mysql_query($query);
while($array=mysql_fetch_assoc($result)){
$poster = $array['friend'];

$user = $_SESSION[username];

if(!isset($_GET['bulletinPage'])){
    $Bpage = 1;
} else {
    $Bpage = $_GET['bulletinPage'];
}

$max_results = 5;


$from = (($Bpage * $max_results) - $max_results);

$query2="SELECT * FROM `bulletins` WHERE `from` = '$poster' ORDER by 'id' DESC LIMIT $from, $max_results";

$result2=mysql_query($query2);

while($array=mysql_fetch_assoc($result2)){

echo "<table bgcolor=#99CCFF width=200><tr bgcolor=#548099><td height=28><b><font color=white>From: <a href='getInfo.php?user=" . $array['from'] . "'>" . $array['from'] . "</a></b><br><b>Date: </b>" .$array['date'];
echo "</b></font></td></tr></table>";
echo "<table bgcolor=#99CCFF width=200><tr bgcolor=#356B8B><td height=25><center><a href=\"showBulletin.php?id=".$array['id']."\">Subject:  ".$array['subject']."</a></center>";
  echo "</td></tr></table><hr>";
}
}

$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM bulletins WHERE `from` = '$poster'"),0);

$total_pages = ceil($total_results / $max_results);
?>
<b>Page: </b>
<?php
if($Bpage > 1){
    $prev = ($Bpage - 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?bulletinPage=$prev\"></a>";
}
for($i = 1; $i <= $total_pages; $i++){
    if(($Bpage) == $i){
        echo "$i ";
        } else {
            echo "<a href=\"".$_SERVER['PHP_SELF']."?bulletinPage=$i\">$i</a> ";
    }
}

if($Bpage < $total_pages){
    $next = ($Bpage + 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?bulletinPage=$next\"></a>";

}
?>[/code]

Share this post


Link to post
Share on other sites
Please do not bump your request so soon after posting it. If you must bump it wait at least [b]4 to 8 hours[/b].

Ken

Share this post


Link to post
Share on other sites

×

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.