balamberas Posted November 17, 2009 Share Posted November 17, 2009 Hi, im trying to insert this code within a html script but the Prev 1 2 3 4 next is not displayed and also the DESC is to responding. Any Ides? <?php include ("connect.php"); // max display per page $per_page = 50; // get start variable $start = $_GET ['start']; // count record $record_count = mysql_num_rows (mysql_query("SELECT * FROM flats ORDER BY date_posted DESC")); //count max pages $max_pages = $record_count / $per_page; // may come out as a decimal if (!$start) $start = 0; // display data $get = mysql_query("SELECT * FROM flats LIMIT $start, $per_page"); while ($row = mysql_fetch_assoc($get)) { // get data $select= $row['type']; $title= $row['title']; $location= $row['location']; $rent= $row['rent']; $description= $row['description']; $contactEmail= $row['contactEmail']; $number= $row['number']; echo "<div><b>$title</b></div>"; echo "<br>"; echo "$select"; echo "<br>"; echo "$rent"; echo "<br>"; echo "$location"; echo "<br>"; echo "$description"; echo "<br>"; echo "$contactEmail"; echo "<br>"; echo "$number"; echo "<hr>"; } // setup the prev and next variables $prev = $start - $per_page; $next = $start + $per_page; //show prev button if (!($start<=0)) echo " <a href='londonfc_flats.php?start=$prev'> << Prev </a> "; //show page numbers // set variable for first page $i=1; for ($x=0;$x<$record_count;$x=$x+$per_page) { if ($start!=$x) echo " <a href='londonfc_flats.php?start=$x'>$i |</a> "; else echo " <a href='londonfc_flats.php?start=$x'><b> $i|</b></a> "; $i++; } //show next button if (!($start>=$record_count-$per_page)) echo " <a href='londonfc_flats.php?start=$next'> Next >></a> "; ?> Link to comment https://forums.phpfreaks.com/topic/181916-pagination-within-a-html-table/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.