supanoob Posted June 22, 2007 Share Posted June 22, 2007 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"eId=$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 More sharing options...
Illusion Posted June 22, 2007 Share Posted June 22, 2007 It should be $limitvalue =( $page * $limit) - $limit; Link to comment https://forums.phpfreaks.com/topic/56696-solved-pagination-loop/#findComment-280019 Share on other sites More sharing options...
supanoob Posted June 22, 2007 Author Share Posted June 22, 2007 It should be $limitvalue =( $page * $limit) - $limit; that did help >< Link to comment https://forums.phpfreaks.com/topic/56696-solved-pagination-loop/#findComment-280029 Share on other sites More sharing options...
supanoob Posted June 22, 2007 Author Share Posted June 22, 2007 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 https://forums.phpfreaks.com/topic/56696-solved-pagination-loop/#findComment-280044 Share on other sites More sharing options...
Illusion Posted June 22, 2007 Share Posted June 22, 2007 If there are only three results for replyid '1' what is the use of using limit 25. Link to comment https://forums.phpfreaks.com/topic/56696-solved-pagination-loop/#findComment-280048 Share on other sites More sharing options...
supanoob Posted June 22, 2007 Author Share Posted June 22, 2007 because thats how many replies per page i want. Link to comment https://forums.phpfreaks.com/topic/56696-solved-pagination-loop/#findComment-280052 Share on other sites More sharing options...
Illusion Posted June 22, 2007 Share Posted June 22, 2007 Did you have more than 3 results for replyid=1 in the database. If you don't have how you can display 25 results per page. Link to comment https://forums.phpfreaks.com/topic/56696-solved-pagination-loop/#findComment-280055 Share on other sites More sharing options...
supanoob Posted June 22, 2007 Author Share Posted June 22, 2007 i have 3 results in that match the criteria. but surely with the limit at 25 i could see upto 25 results before needing to move to page 2 Link to comment https://forums.phpfreaks.com/topic/56696-solved-pagination-loop/#findComment-280056 Share on other sites More sharing options...
Illusion Posted June 22, 2007 Share Posted June 22, 2007 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 https://forums.phpfreaks.com/topic/56696-solved-pagination-loop/#findComment-280059 Share on other sites More sharing options...
supanoob Posted June 22, 2007 Author Share Posted June 22, 2007 so why will it display 1 result and not the other 2? Link to comment https://forums.phpfreaks.com/topic/56696-solved-pagination-loop/#findComment-280062 Share on other sites More sharing options...
Illusion Posted June 22, 2007 Share Posted June 22, 2007 It will display 3. Link to comment https://forums.phpfreaks.com/topic/56696-solved-pagination-loop/#findComment-280066 Share on other sites More sharing options...
supanoob Posted June 22, 2007 Author Share Posted June 22, 2007 it doesnt that what i need to fix. it will only display 1 of the 3 results. i have removed the LIMIT $limitvalue, $limit part and it still only diaplays 1 result. Link to comment https://forums.phpfreaks.com/topic/56696-solved-pagination-loop/#findComment-280067 Share on other sites More sharing options...
supanoob Posted June 23, 2007 Author Share Posted June 23, 2007 anyone? Link to comment https://forums.phpfreaks.com/topic/56696-solved-pagination-loop/#findComment-280576 Share on other sites More sharing options...
teng84 Posted June 23, 2007 Share Posted June 23, 2007 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 https://forums.phpfreaks.com/topic/56696-solved-pagination-loop/#findComment-280584 Share on other sites More sharing options...
supanoob Posted June 23, 2007 Author Share Posted June 23, 2007 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 Link to comment https://forums.phpfreaks.com/topic/56696-solved-pagination-loop/#findComment-280592 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.