Jump to content

[SOLVED] pagination + loop


supanoob

Recommended Posts

Ok so i have the following code:

 

 <?php
   $limit          = 25;               
    $query_count    = "SELECT * FROM forum where reply_to='$reply_to'";    
    $result_count   = mysql_query($query_count);    
    $totalrows      = mysql_num_rows($result_count); 

if(empty($page)){
        $page = 1;
    }
        

    $limitvalue = $page * $limit - ($limit); 
    $query  = "SELECT * FROM forum where reply_to='$reply_to' AND post_type='reply' LIMIT $limitvalue, $limit";        
    $result = mysql_query($query) or die("Error: " . mysql_error()); 

    if(mysql_num_rows($result) == 0){
        echo("");
    }
while($row = mysql_fetch_array($result))
{
$post_body=($row['post_body']);
$posted_on=($row['posted_on']);
$posted_at=($row['posted_at']);
$posted_by_id=($row['posted_by_id']);
$forum_name=($row['forum_name']);
$post_id=($row['post_id']);

$query="select name, post_count, game_rank, char_level from accounts where account_id='$posted_by_id'";
$result=mysql_query($query);
if (!$result)
{
die(mysql_error());
}
$num_rows=mysql_num_rows($result);

$row=mysql_fetch_array($result);
$name_1=($row['name']);
$post_count_1=($row['post_count']);
$forum_rank_1=($row['forum_rank']);
$game_rank_1=($row['game_rank']);
$char_level_1=($row['char_level']);

echo "<center><a name=$post_id><table border=\"0\" width=\"90%\" id=\"table1\" cellspacing=\"1\">

<tr>
	<td width=\"24%\" align=\"center\" bgcolor=\"#333333\">Author Info</td>
	<td align=\"center\" bgcolor=\"#333333\">Message</td>
</tr>
<tr>
	<td width=\"24%\" valign=\"top\" bgcolor=\"#666666\">Name: $name_1<br>
	Game Rank: $game_rank_1<br>
	Guild: None<br>
	Posts: $post_count_1<br>
	Level: $char_level_1<br>
    Posted At: $posted_at<br>
    Posted On: $posted_on</td></td>
	<td valign=\"top\" bgcolor=\"#666666\">$post_body<br>
	<br>
 <table border=\"0\" width=\"100%\" id=\"table2\">
		<tr>
			<td bgcolor=\"#333333\">This will be the signature<br>
 </td>
		</tr>
	</table>[Options: <a href=\"view_post.php?step=$step&post_id=$reply_to&action=quote&quoteId=$post_id#reply\">Quote</a>"; if ($account_id == $posted_by_id){echo "| Delete | Edit";}
    
    if ($game_rank == 'Owner' || $game_rank == 'Moderator') {echo " | Fine | Ban";}
    
    
	echo "]
	</td>
</tr>
</table>
";
}

?>

 

the problem is it is only echoing 1 of the results in the database. Now i have tested it on several of the boards i have and the same problem occurs on them all ><

 

Can you see why?

Link to comment
https://forums.phpfreaks.com/topic/56696-solved-pagination-loop/
Share on other sites

some extra info when i echo

 

Limit, query_count, reusult_count total rows and limitvalue i get the following result

 

limit value:0

limit: 25

query count: SELECT * FROM forum where reply_to='1'

Result count: Resource id #14

total rows: 3

 

hope that helps solve the problem some more.

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.