graham23s Posted May 17, 2007 Share Posted May 17, 2007 Hi Guys, i have a small problem with this pagination script i have added, i put the number of results to be displayed to 1, which leaves 4 pages to look at (4 entries in the database) but it displays all the rows, can anyone see what i have done wrong: <?php ######################################################################################################### if (isset($_GET['pageno'])) { $pageno = $_GET['pageno']; } else { $pageno = 1; } // if $query6 = "SELECT count(*) FROM `TEST`"; $result6 = mysql_query($query6) or die (mysql_error()); $query_data = mysql_fetch_row($result6); $numrows = $query_data[0]; $rows_per_page = 1; $lastpage = ceil($numrows/$rows_per_page); $pageno = (int)$pageno; if ($pageno < 1) { $pageno = 1; } elseif ($pageno > $lastpage) { $pageno = $lastpage; } // if $limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page; $query = "SELECT * FROM `TEST` $limit"; $result = mysql_query($query) or die (mysql_error()); // Place info here...///////////////////////////////////////////////////////////// // start the table.../////////////////////////////////////////////////////////////// echo '<br /><h4>TEST</h3> <table width="600" border="1" bordercolor="#000000" cellspacing="0" cellpadding="2" /> <tr> <th>TEST</th><th>TEST</th><th>TEST</th><th>TEST</th><th>TEST</th> </tr> <tr>'; // get the latest nzbs.../////////////////////////////////////////////////////////// $query1 = "SELECT * FROM `TEST`"; $result1 = mysql_query($query1) or die (mysql_error()); // loop the results out...////////////////////////////////////////////////////////// while ($row = mysql_fetch_array($result1)) { $id = $row['id']; $category = $row['category']; $added = $row['date_added']; $poster_name = $row['poster_name']; // get the users name clickable...///////////////////////////////////////////////// $query2 = "SELECT * FROM `TEST` WHERE `username`='$poster_name'"; $result2 = mysql_query($query2) or die (mysql_error()); $rows = mysql_fetch_array($result2) or die (mysql_error()); // the id and username.../////////////////////////////////////////////////////////// $user_id = $rows['id']; $username = $rows['username']; $query3 = "SELECT * FROM `comments` WHERE `id`='$id'"; $result3 = mysql_query($query3) or die (mysql_error()); $num_comments = mysql_num_rows($result3); } echo '</table><br />'; // Place info here...///////////////////////////////////////////////////////////// if ($pageno == 1) { echo " FIRST PREV "; } else { echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1'>FIRST</a> "; $prevpage = $pageno-1; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'>PREV</a> "; } // if echo " ( Page $pageno of $lastpage ) "; if ($pageno == $lastpage) { echo " NEXT LAST "; } else { $nextpage = $pageno+1; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'>NEXT</a> "; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage'>LAST</a> "; echo "<br /><br />"; } // if ?> Thanks for any help guys Graham Quote Link to comment https://forums.phpfreaks.com/topic/51898-pagination-placement-question/ Share on other sites More sharing options...
soycharliente Posted May 17, 2007 Share Posted May 17, 2007 $query_data = mysql_fetch_row($result6); $numrows = $query_data[0]; That part? Isn't is mysql_fetch_array()? And try using $numrows = mysql_num_rows($result6). Quote Link to comment https://forums.phpfreaks.com/topic/51898-pagination-placement-question/#findComment-255843 Share on other sites More sharing options...
graham23s Posted May 17, 2007 Author Share Posted May 17, 2007 Yeah that's what i was thinking, can anyone recommend a good tutorial on pagination at all, it's the only thing i find hard about PHP. cheers Graham Quote Link to comment https://forums.phpfreaks.com/topic/51898-pagination-placement-question/#findComment-255855 Share on other sites More sharing options...
marf Posted May 17, 2007 Share Posted May 17, 2007 I must be having a brain cramp or something. I can't see where your echoing the variables out in that TEST TEST TEST table (in the while loop I'm assuming). Quote Link to comment https://forums.phpfreaks.com/topic/51898-pagination-placement-question/#findComment-255859 Share on other sites More sharing options...
hitman6003 Posted May 17, 2007 Share Posted May 17, 2007 http://www.phpfreaks.com/tutorial_cat/25/Page-Number--Pagination.php Quote Link to comment https://forums.phpfreaks.com/topic/51898-pagination-placement-question/#findComment-255870 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.