Woodburn2006 Posted September 17, 2008 Share Posted September 17, 2008 i am creating a photo gallery and i want to only display a few images as thumbnails at a time so that users click these thumbnails and they view the large image. when the gallery has more images i want to display the photos 5 at a time with page numbers so users can flick through the pages. i have done this before but cannot work out why i cannot get it to work this time. this is the code i am using for this section of this page: <? if(empty($page)){$page = 1;} $limit= 5; $query_count = "SELECT count(*) AS rowcount FROM photos WHERE photo_id LIKE '$a%'"; $result_count = mysql_query($query_count, $connection); $row_count = mysql_fetch_array($result_count, MYSQL_ASSOC); $totalrows = $row_count['rowcount']; $limitvalue = $page * $limit - ($limit); $query_thumbs = "SELECT * FROM photos WHERE photo_id LIKE '$a%' ORDER BY photo_id LIMIT $limitvalue, $limit"; $result_thumbs = mysql_query($query_thumbs) or die("Error: " . mysql_error()); while ($row_thumbs = mysql_fetch_array($result_thumbs)) { extract($row_thumbs); echo "<img id='$photo_id' src='$url' height='65px'> "; } $numofpages = ceil($totalrows / $limit); if($page > $numofpages){ $page = $numofpages; } if($page > 1){ $pageprev = $page - 1; echo ("<a href=\"$PHP_SELF?go=photos&page=".$pageprev."\"><< PREV</a> - "); } for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?go=photos&page=".$i."\">$i</a> "); } } if($page < $numofpages){ $pagenext = $page + 1; echo(" - <a href=\"$PHP_SELF?go=photos&page=".$pagenext."\">NEXT >></a>"); } ?> </td> the layout is not great at the moment as im stillgetting it to function but the site addy is: http://travelling.dw20.co.uk/?go=photos if anyone can see what is going wrong it would much help thanks Link to comment https://forums.phpfreaks.com/topic/124651-page-numbering/ Share on other sites More sharing options...
sasa Posted September 17, 2008 Share Posted September 17, 2008 change line if(empty($page)){$page = 1;} to $page = $_GET['page'] ? (int) $_GET['page'] : 1; Link to comment https://forums.phpfreaks.com/topic/124651-page-numbering/#findComment-643804 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.