phpbeginner Posted April 11, 2007 Share Posted April 11, 2007 I have the simple pagination script from the tutorials and I can't seem to get the page links to work ..... <?php $limit = 5; $query_count = "SELECT count(*) FROM homes where area='$area'"; $result_count = mysql_query($query_count); $totalrows = mysql_num_rows($result_count); if(empty($page)){ $page = 1; } $limitvalue = $page * $limit - ($limit); $query = "SELECT * FROM homes where area='$area' ORDER BY `price` ASC LIMIT $limitvalue, $limit"; $result = mysql_query($query) or die("Error: " . mysql_error()); if(mysql_num_rows($result) == 0){ echo("Nothing to Display!"); } while ($a_row =mysql_fetch_array ($result) ) { My page information is displaying here correctly and the limit function works but below my page numbers will not link. If I manually type in the address bar mylink&page=3, the 1 at the bottom is linked and I can then go back to mylink&page1 } if($page != 1){ $pageprev = $page--; echo("<a href=\"$PHP_SELF?area=$area&page=$pageprev\">PREV".$limit."</a> "); }else{ echo("PREV".$limit." "); } $numofpages = $totalrows / $limit; for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?area=$area?page=$i\">$i</a> "); } } if(($totalrows % $limit) != 0){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?area=$area?page=$i\">$i</a> "); } } if(($totalrows - ($limit * $page)) > 0){ $pagenext = $page++; echo("<a href=\"$PHP_SELF?area=$area?page=$pagenext\">NEXT".$limit."</a>"); }else{ echo("NEXT".$limit); } mysql_free_result($result); ?> Thanks for your help and patience with me ! Link to comment https://forums.phpfreaks.com/topic/46656-pagination-link-problem/ Share on other sites More sharing options...
clown[NOR] Posted April 11, 2007 Share Posted April 11, 2007 try changing the echo lines to echo = "value inside here"; Link to comment https://forums.phpfreaks.com/topic/46656-pagination-link-problem/#findComment-227259 Share on other sites More sharing options...
phpbeginner Posted April 11, 2007 Author Share Posted April 11, 2007 Thanks but I get the same thing. No page links working. Link to comment https://forums.phpfreaks.com/topic/46656-pagination-link-problem/#findComment-227263 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.