saikiran Posted August 11, 2006 Share Posted August 11, 2006 hi,I am running a photo gallery in my site. in which , i am having a thumbnail page and a popup image page,what i am doing is when user clicks the thumbnail, the bigger picture should open in a popup in a separate page.I would like to add a navigation link in the popup page. i.e. with in the popup page, user can go and view the rest of the images in the gallery also.[color=red]i am providing this as 1,2 ,3,4,5.....[Next][Previous] . format.i am not able to run the navigation part properly....[/color]This is what the code for the 2 pages:[color=red]Thumbnails page code [/color][code]<?php include_once('config.php');$psql = "select * from bhakt_photo";$result = mysql_query($psql);if($result){ while($row = mysql_fetch_array($result,MYSQL_BOTH)) { echo "<table>"; echo "<tr>"; echo "<td>";?> <a href='bhakti_popnew.php?id=<?php echo $row['id'];?>'><img src="http://www.seher.in/gall_upload/ <?php echo $row['mid_img'];?>" border="0" ></a> <?php echo "</td>"; echo "</table>"; }}?>[/code]-----Popup page code-------------[code]<?php include('config.php');//new code$id=$_GET['id']; //this the Id i am getting for the images// how many rows to show per page$rowsPerPage = 1;// by default we show first page$pageNum = 1;// if $_GET['page'] defined, use it as page numberif(isset($_GET['page'])){ $pageNum = $_GET['page'];}// counting the offset$offset = ($pageNum - 1) * $rowsPerPage;//$offset = $rowsPerPage;$query = " SELECT * FROM bhakt_photo where id=$id " . " LIMIT $offset, $rowsPerPage";echo $query."<br>" ;$result = mysql_query($query) or die('Error, query failed');?><body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <?php while($row = mysql_fetch_array($result)) { echo $row['big_img']; } ?> </table> <br><br><?php // how many rows we have in database$query = "SELECT COUNT(big_img) AS numrows FROM bhakt_photo ";$result = mysql_query($query) or die('Error, query failed');$row = mysql_fetch_array($result, MYSQL_ASSOC);$numrows = $row['numrows'];// how many pages we have when using paging?$maxPage = ceil($numrows/$rowsPerPage);// print the link to access each page$self = $_SERVER['PHP_SELF'];$nav = '';for($page = 1; $page <= $maxPage; $page++){ if ($page == $pageNum) { $nav .= " $page "; // no need to create a link to current page } else { $nav .= " <a href=\"$self?page=$page\">$page</a> "; }}if ($pageNum > 1){ $page = $pageNum - 1; $id = $id-1; $prev = " <a href=\"$self?page=$page&id=$id\">[Prev]</a> "; $first = " <a href=\"$self?page=1&id=$id\">[First Page]</a> "; //$prev = " <a href=\"$self?page=$page\">[Prev]</a> "; //$first = " <a href=\"$self?page=1\">[First Page]</a> ";}else{ $prev = ' '; // we're on page one, don't print previous link $first = ' '; // nor the first page link}if ($pageNum < $maxPage){ $page = $pageNum + 1; $id = $id +1; echo "<b>". $id."<br>"; $next = " <a href=\"$self?page=$page&id=$id\">[Next]</a> "; $last = " <a href=\"$self?page=$maxPage&id=$id\">[Last Page]</a> "; //$next = " <a href=\"$self?page=$page\">[Next]</a> "; //$last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> ";}else{ $next = ' '; // we're on the last page, don't print next link $last = ' '; // nor the last page link}// print the navigation linkecho $first . $prev . $nav . $next . $last;// and close the database connection// ... and we're done!?>[/code]the problem what i assume is - the 'id' value is not passing in the subsquent pages properly.i have checked readymade photogallery packages...but i would like to have my own. I am not an expert in PHP too.can anyone just tell me whats the problem in my code and help me out in completing this one.cheerssaikiransaisen76@hotmail.com Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 11, 2006 Share Posted August 11, 2006 weres the javascript Quote Link to comment Share on other sites More sharing options...
saikiran Posted August 11, 2006 Author Share Posted August 11, 2006 hi,this is how i am calling it into the popup.sorry for not putting the popup one<?php include_once('config.php');$psql = "select * from bhakt_photo";$result = mysql_query($psql);if($result){ while($row = mysql_fetch_array($result,MYSQL_BOTH)) { echo "<table>"; echo "<tr>"; echo "<td>";?>[b]<a href="javascript:;" onClick = "window.open('bhakti_popnew.php?id=<?php echo $row['id'];?>','Gallery','height=700,width=589,scrolling=yes')"><img src="http://www.seher.in/uploads/<?php echo $row['mid_img'];?>" border="0" ></a>[/b] <?php echo "</td>"; echo "</table>"; }}?>cheerssaikiran Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.