i have been on heaps of website trying to get scripts for a pagination but they all seem to not work. so i was wondering if someone could write me one.. these are the things it will have: table name = supercross_race_reviews and thats it really. If anyone could help that would be awesome THANKS KURT
A lot of it depends on how you currently display you content. if you are using a request to do a page number, and pulling it from a data base you should use LIMIT in you mysql. It just becomes a math problem at that point.
Well this is the code thats in it now.. <?php require('connect.php'); $result = mysql_query("SELECT * FROM supercross_race_reviews ORDER BY id DESC") or die(mysql_error()); echo "<table width='70%' cellspacing='10'>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; // arrow echo ("<img src='arrow.gif'>"); echo " "; // article name echo '<a style="font-size: 25px" href="'. $row['url'] .'">'. $row['article_name'] .'</a>'; echo "</td></tr><tr><td>"; // author + date echo $row['author']; echo " "; echo $row['date']; echo "</td></tr><tr><td>"; // Description echo "Brief Decription : "; echo " "; echo $row['description']; echo "<hr /></td></tr>"; } ?> PHP: Thanks
<?php $results_per_page=25; $page=is_numeric(@(int)$_GET['page'])?@(int)$_GET['page']:1; require('connect.php'); //Get amount of pages// $arr=mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM supercross_race_reviews"));; $amount_of_results=$arr[0]; $pages=ceil($arr/$results_per_page); //Fetch Results $result = mysql_query("SELECT * FROM supercross_race_reviews ORDER BY id DESC LIMIT ".($page-1)*$results_per_page.",".$results_per_page) or die(mysql_error()); echo "<table width='70%' cellspacing='10'>"; while($row = mysql_fetch_array( $result )) { echo "<tr><td>"; echo ("<img src='arrow.gif'>"); echo " "; echo '<a style="font-size: 25px" href="'. $row['url'] .'">'. $row['article_name'] .'</a>'; echo "</td></tr><tr><td>"; echo $row['author']; echo " "; echo $row['date']; echo "</td></tr><tr><td>"; echo "Brief Decription : "; echo " "; echo $row['description']; echo "<hr /></td></tr>"; } PHP: Only thing left to do is displaying links to the different pages. (fyi, I can't check if it actually works. But I suppose you get the idea)
i tested it out and this error came Fatal error: Unsupported operand types in /home/motorbik/public_html/supercross race reviews.php on line 51