joshgarrod Posted January 20, 2009 Share Posted January 20, 2009 Hi all, I am having problems with pagination for my list of items. Bascially it works to the extent of showing only 10 results but when I click the Next Page link it goes to a url which is part of my local directory for the website... Any ideas? thanks in advance: <?php error_reporting (E_ALL ^ E_NOTICE); $records_per_page = 10; //number of records to be displayed per page (!$_GET['start']) ? $start = 0 : $start = $_GET['start']; mysql_connect("serv", "usr", "pass") or die(mysql_error()); mysql_select_db("quest") or die(mysql_error()); $query = "SELECT COUNT(*) FROM table"; $result = mysql_query($query) or die ('Error in query: $query. ' . mysql_error()); $data = mysql_fetch_row($result); $total_records = $data[0]; if (($total_records > 0) && ($start < $total_records)) { //delete from here up to start of php is broke $cond = ""; if(isset($_POST['weight']) && is_numeric($_POST['weight'])) { $weight = intval($_POST['weight']); $cond = " WHERE weightla <= {$weight}"; } $data = mysql_query("SELECT * FROM table LIMIT $start, $records_per_page".$cond); $result = mysql_query($query) or die ('Error in query: $query ' . mysql_error()); while($info = mysql_fetch_array( $data )) { Print "<div id=\"caravan_row\">"; Print "<div id=\"logo\"><a href='view_used_caravan.php?ref=".$info['ref'] ."'><img src=\"images/".$info['make'] . ".gif\" border=\"0\" /></a></div>"; Print "<div id=\"image\"><a href='view_used_caravan.php?ref=".$info['ref'] ."'><img src=\"".$info['image1'] . "\" border=\"0\" /></a></div>"; Print "<div id=\"specifications\">"; Print "<div id=\"make\"><h1></strong>".$info['make'] . " " . $info['model'] ."</h1></div>"; Print "<div id=\"price\"><span class=\"price\">£".$info['price'] . "</span></div>"; Print "<div id=\"more\"><a href='view_used_caravan.php?ref=".$info['ref'] ."'>More info>></a></div>"; Print "<div id=\"year\"><strong>Year: </strong>".$info['year'] . " </div>"; Print "<div id=\"weightun\"><strong>MIRO: </strong>".$info['weightun'] . "kg</div>"; Print "<div id=\"berth\"><img src=\"images/".$info['berth'] . ".gif\" class=\"berth\" />" .$info['berth'] . " berth</div>"; Print "<div id=\"weightla\"><strong>MTPLM: </strong>".$info['weightla'] . "kg</div>"; Print "<div id=\"lengthex\"><strong>Shipping length: </strong>".$info['lengthex'] . "ft</div>"; Print "</div>"; Print "</div>"; } if ($start >= $records_per_page) { echo "<a href=" . $_SERVER['PHP_SELF'] . "?start=" . ($start-$records_per_page) . ">Previous Page</a> "; } if ($start+$records_per_page < $total_records && $start >= 0) { echo "<a href=" . $_SERVER['PHP_SELF'] . "?start=" . ($start+$records_per_page) . ">Next Page</a>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/141642-pagination-problems/ Share on other sites More sharing options...
DeanWhitehouse Posted January 20, 2009 Share Posted January 20, 2009 Have a look at the tutorial on this site for pagination, it will explain it all. Link to comment https://forums.phpfreaks.com/topic/141642-pagination-problems/#findComment-741435 Share on other sites More sharing options...
joshgarrod Posted January 20, 2009 Author Share Posted January 20, 2009 Hi, I followed a similar tutorial and have checked it through but I cannot see where I have gone wrong. It is more than likely something really silly. Link to comment https://forums.phpfreaks.com/topic/141642-pagination-problems/#findComment-741644 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.