liam1412 Posted January 18, 2007 Share Posted January 18, 2007 Hi I have tried a different method of pagination. I am nw getting a parse error that points toward the last line of the code. i assume it's a semi-colon or curly bracket missing but can't find it. Can anyone help,Thanks[code]<?php$limit = 20;$query_count = "SELECT count(*)FROM forum_question WHERE forum_id = $forum_id";$result_count = mysql_query($query_count);$total_rows = mysql_num_rows($result_count);if(empty($page)){ $page = 1; } $limitvalue = $page * $limit - ($limit);$topic_query = "SELECT * FROM forum_question WHERE forum_id = $forum_id LIMIT $limitvalue, $limit";$topic_result = mysql_query($topic_query)or die("Error: " . mysql_error());while($topic_rows = mysql_fetch_array($topic_result)){ //loop table row while topic exists?><tr bgcolor="#6d6d6d"> <td width="60" align="center"> <?php if($topic_rows['topic_status'] == 1){ echo '<img src = "images/norm_post_locked.jpg" width="35" height="41" alt="Hot Topic" />';} elseif($topic_rows['topic_status'] == 2){ echo '<img src = "images/norm_post_sticky.jpg" width="35" height="41" alt="Norm Topic" />';} elseif($topic_rows['topic_status'] == 3){ echo '<img src = "images/norm_post_locked_sticky.jpg" width="35" height="41" alt="Hot Topic" />';} elseif($topic_rows['topic_status'] == 4){ echo '<img src = "images/hot_post.jpg" width="35" height="41" alt="Norm Topic" />';} elseif($topic_rows['topic_status'] == 5){ echo '<img src = "images/hot_post_locked.jpg" width="35" height="41" alt="Hot Topic" />';} elseif($topic_rows['topic_status'] == 6){ echo '<img src = "images/hot_post_sticky.jpg" width="35" height="41" alt="Norm Topic" />';} elseif($topic_rows['topic_status'] == 7){ echo '<img src = "images/hot_post_locked_sticky.jpg" width="35" height="41" alt="Hot Topic" />';} elseif($topic_rows['topic_status'] == 0){ echo '<img src = "images/norm_post.jpg" width="35" height="41" alt="Hot Topic" />';} ?> <td width="240"> <table width="240" cellspacing="0" cellpadding="0" border="0"> <tr> <td><a href="view_topic.php?topic_id=<?php echo $topic_rows['topic_id'];?>"><?php echo $topic_rows['topic'];?></a></td> </tr> <tr> <td align="right"> <?php if($_SESSION['user_level'] != 0){ ?> <br /> <a href='lock_thread.php?topic_id=".$topic_rows['topic_id']."'><img src='images/lock_thread.jpg' width="25" height="25" border="0" alt='Lock Thread' /></a>   <a href="make_sticky.php?topic_id=".$topic_rows['topic_id'].""><img src="images/make_sticky.jpg" width="25" height="25" border="0" alt="Make Sticky" /></a>   <a href="delete_thread.php?topic_id=<?php echo $topic_rows['topic_id']; ?>"><img src="images/delete.jpg" width="25" height="25" border="0" alt="Delete Thread" /></a> <?php }; ?> </td> </tr> </table> </td> <td width="100" align="center"><p class="grey"><?php echo $topic_rows['topic_starter_name'];?></p></td> <td width="45" align="center"><p class="grey"><?php echo $topic_rows['topic_view'];?></p></td> <td width="45" align="center"><p class="grey"><?php echo $topic_rows['topic_reply'];?></p></td> <td width="110" align="left"><p class="lastpost"><b>Made By: </b><?php echo $topic_rows['last_post_by'];?><br /><b>On: </b><?php echo $topic_rows['last_post_date_time'];?></b></p></td></tr><?phpif($page != 1){ $pageprev = $page--;echo("<a href=\"$PHPSELF&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=\"$PHP_SELF&page=$i\">$i</a> "); } } if(($totalrows % $limit) != 0){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF&page=$i\">$i</a> "); } } if(($totalrows - ($limit * $page)) > 0){ $pagenext = $page++; echo("<a href=\"$PHP_SELF?page=$pagenext\">NEXT".$limit."</a>"); }else{ echo("NEXT".$limit); } } mysql_close();?></table><?php include 'footer.php';?>[/code] Link to comment https://forums.phpfreaks.com/topic/34700-pagination-help-again/ Share on other sites More sharing options...
liam1412 Posted January 18, 2007 Author Share Posted January 18, 2007 I have managed to resolve the first issue but now the Prev and Next links are not links and it isn't adding the page numbers in between the prev and next.I have my limit set at 20When my forum as more than 20 topics the prev Next Link looks like thisPREV 1 NEXT -- But none of them ar actually linksPlease help Link to comment https://forums.phpfreaks.com/topic/34700-pagination-help-again/#findComment-163543 Share on other sites More sharing options...
liam1412 Posted January 18, 2007 Author Share Posted January 18, 2007 I think it's acting as if there isn't any more records there but there is definatley.Here is my ammended code I have up to now.[code]<?php$limit = 20;$query_count = "SELECT count(*)FROM forum_question WHERE topic_forum_id = $forum_id";$result_count = mysql_query($query_count);$total_rows = mysql_num_rows($result_count);if(empty($page)){ $page = 1; } $limitvalue = $page * $limit - ($limit);$topic_query = "SELECT * FROM forum_question WHERE topic_forum_id = $forum_id LIMIT $limitvalue, $limit";$topic_result = mysql_query($topic_query)or die("Error: " . mysql_error());while($topic_rows = mysql_fetch_array($topic_result)){ //loop table row while topic exists?><tr bgcolor="#6d6d6d"> <td width="60" align="center"> <?php if($topic_rows['topic_status'] == 1){ echo '<img src = "images/norm_post_locked.jpg" width="35" height="41" alt="Hot Topic" />';} elseif($topic_rows['topic_status'] == 2){ echo '<img src = "images/norm_post_sticky.jpg" width="35" height="41" alt="Norm Topic" />';} elseif($topic_rows['topic_status'] == 3){ echo '<img src = "images/norm_post_locked_sticky.jpg" width="35" height="41" alt="Hot Topic" />';} elseif($topic_rows['topic_status'] == 4){ echo '<img src = "images/hot_post.jpg" width="35" height="41" alt="Norm Topic" />';} elseif($topic_rows['topic_status'] == 5){ echo '<img src = "images/hot_post_locked.jpg" width="35" height="41" alt="Hot Topic" />';} elseif($topic_rows['topic_status'] == 6){ echo '<img src = "images/hot_post_sticky.jpg" width="35" height="41" alt="Norm Topic" />';} elseif($topic_rows['topic_status'] == 7){ echo '<img src = "images/hot_post_locked_sticky.jpg" width="35" height="41" alt="Hot Topic" />';} elseif($topic_rows['topic_status'] == 0){ echo '<img src = "images/norm_post.jpg" width="35" height="41" alt="Hot Topic" />';} ?> <td width="240"> <table width="240" cellspacing="0" cellpadding="0" border="0"> <tr> <td><a href="view_topic.php?topic_id=<?php echo $topic_rows['topic_id'];?>"><?php echo $topic_rows['topic'];?></a></td> </tr> <tr> <td align="right"> <?php if($_SESSION['user_level'] != 0){ ?> <br /> <a href='lock_thread.php?topic_id=".$topic_rows['topic_id']."'><img src='images/lock_thread.jpg' width="25" height="25" border="0" alt='Lock Thread' /></a>   <a href="make_sticky.php?topic_id=".$topic_rows['topic_id'].""><img src="images/make_sticky.jpg" width="25" height="25" border="0" alt="Make Sticky" /></a>   <a href="delete_thread.php?topic_id=<?php echo $topic_rows['topic_id']; ?>"><img src="images/delete.jpg" width="25" height="25" border="0" alt="Delete Thread" /></a> <?php }; ?> </td> </tr> </table> </td> <td width="100" align="center"><p class="grey"><?php echo $topic_rows['topic_starter_name'];?></p></td> <td width="45" align="center"><p class="grey"><?php echo $topic_rows['topic_view'];?></p></td> <td width="45" align="center"><p class="grey"><?php echo $topic_rows['topic_reply'];?></p></td> <td width="110" align="left"><p class="lastpost"><b>Made By: </b><?php echo $topic_rows['last_post_by'];?><br /><b>On: </b><?php echo $topic_rows['last_post_date_time'];?></b></p></td></tr><?php}if($page != 1){ $pageprev = $page--;echo("<a href=\"$PHPSELF&page=$pageprev\">PREV</a> ");}else{echo ("PREV");$numofpages = $total_rows / $limit; for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ echo($i." "); }else echo("<a href=\"$PHP_SELF&page=$i\">$i</a> "); } } if(($total_rows % $limit) != 0){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF&page=$i\">$i</a> "); } } if(($total_rows - ($limit * $page)) > 0){ $pagenext = $page++; echo("<a href=\"$PHP_SELF?page=$pagenext\">NEXT</a>"); }else{ echo("NEXT"); } mysql_close();?></table><?php include 'footer.php';?>[/code] Link to comment https://forums.phpfreaks.com/topic/34700-pagination-help-again/#findComment-163544 Share on other sites More sharing options...
liam1412 Posted January 18, 2007 Author Share Posted January 18, 2007 **BUMP** Link to comment https://forums.phpfreaks.com/topic/34700-pagination-help-again/#findComment-163598 Share on other sites More sharing options...
liam1412 Posted January 18, 2007 Author Share Posted January 18, 2007 Another Bump which im sorry for but I have followed the code exactly as it is in the tutorial on here and it isn't working. please can someone tell me what is wrong with it.Thanks Link to comment https://forums.phpfreaks.com/topic/34700-pagination-help-again/#findComment-163798 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.