jerryroy Posted June 19, 2007 Share Posted June 19, 2007 the links in my code not working for some strange reason i don't know why heres a look at the code <?php $db = mysql_connect("localhost","root","docdre") or die ("Error Could not Connect".mysql_error()); $dbn = "sitenews"; mysql_select_db ($dbn,$db) or die ("Select DB Error".mysql_error()); $rows_per_page = 10; if(!isset($_GET['page'])) { $page = 1; } else{ $page = $_GET['page']; } $offset = (($page * $rows_per_page) - $rows_per_page); $post = mysql_query("select * from post limit $offset,$rows_per_page" ); echo "Latest Blog!!!"; while ($row = mysql_fetch_array($post) ){ echo "<br>"; echo "DATE ADDED: "; echo $row [ "date_added" ] ; echo "<br>"; echo "NAME: "; echo $row ["user_name" ]; echo "<br>"; echo "SUBJECT: "; echo $row ["subject" ]; echo "<br>"; echo "COMMENTS: "; echo $row ["comments" ]; echo "<br>"; } $total_results = mysql_result(mysql_query("select count(*) as num from post"),0); $total_pages = ceil($total_results / $rows_per_page); echo "<center>Select a Page<br />"; // Build Previous Link if($page > 1){ $prev = ($page - 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?ref=viewpost?page=$prev\"><<Previous</a> ";// } for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "$i "; } else { echo "<a href=\"".$_SERVER['PHP_SELF']."?ref=viewpost?page=$i\">$i</a> ";// } } // Build Next Link if($page < $total_pages){ $next = ($page + 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?ref=viewpost?page=$next\">Next>></a>";// } echo "</center>"; mysql_close($db); ?> Link to comment https://forums.phpfreaks.com/topic/56141-pagination-problems/ Share on other sites More sharing options...
teng84 Posted June 19, 2007 Share Posted June 19, 2007 what are the errors??? Link to comment https://forums.phpfreaks.com/topic/56141-pagination-problems/#findComment-277331 Share on other sites More sharing options...
hackerkts Posted June 19, 2007 Share Posted June 19, 2007 Try to put or die("MySQL Error: ".mysql_error()) on all your queries, maybe is your table structure problem itself.. Link to comment https://forums.phpfreaks.com/topic/56141-pagination-problems/#findComment-277333 Share on other sites More sharing options...
jerryroy Posted June 19, 2007 Author Share Posted June 19, 2007 well when i view the first page and click on the link the next page is blank an i cant figure out why as yet Link to comment https://forums.phpfreaks.com/topic/56141-pagination-problems/#findComment-277340 Share on other sites More sharing options...
hackerkts Posted June 19, 2007 Share Posted June 19, 2007 Try what I say, check if there's error on your query, if it's not then try to replace $_SERVER['PHP_SELF'] with your full http. Link to comment https://forums.phpfreaks.com/topic/56141-pagination-problems/#findComment-277348 Share on other sites More sharing options...
jerryroy Posted June 19, 2007 Author Share Posted June 19, 2007 it's not the query because i see the first 10 results and i place my full http and the page came up blank plus i cant tell if theres an error because i cant see errors and i enabled them in the ini file Link to comment https://forums.phpfreaks.com/topic/56141-pagination-problems/#findComment-277359 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.