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
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.

Link to comment
Share on other sites

What does it mean by using LIMIT 25 in the query is , if more than 25 results are returned for the particular query it will fetches 25. It doesn't mean that even if u don't have 25 results it will display 25 results for u.

Link to comment
Share on other sites

echo1ng 1???

$query="select name, post_count, game_rank, char_level from accounts where account_id='$posted_by_id'";

 

base on the condition i think where account_id='$posted_by_id is the limit because there is only one account_id

Link to comment
Share on other sites

echo1ng 1???

$query="select name, post_count, game_rank, char_level from accounts where account_id='$posted_by_id'";

 

base on the condition i think where account_id='$posted_by_id is the limit because there is only one account_id

 

sorted now thanks :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.