Guber-X Posted July 29, 2009 Share Posted July 29, 2009 okay so basicly it works but the problem is that when you try to view that last image, it doesnt load. and im lost in how to write the code. if anyone could help me out that would be great link to page to see whats up lol http://70.66.201.161/timeless/photos.php?cat_id=2&page=1 <?php echo "<br /><br />"; $result3 = mysql_query("SELECT * FROM photo_img WHERE pic_id=$pic_id LIMIT 1"); if (!$result3) { die("query failed: " . msql_error()); } $result4 = mysql_query("SELECT * FROM photo_cat WHERE cat_id=$category ORDER by id LIMIT 1"); if (!$result4) { die("query failed: " . msql_error()); } while ($row = mysql_fetch_array($result4)) { list($id, $cat_name, $cat_id, $location) = $row; while ($row = mysql_fetch_array($result3)) { list($id, $pic_id, $file_name, $cat_id, $comment,) = $row; $resultNxt = mysql_query("SELECT * FROM photo_img WHERE cat_id=$category AND pic_id > $pic_id LIMIT 1"); if (!resultNxt) { die("query failed: " . msql_error()); } while ($nextrow = mysql_fetch_array($resultNxt)) { $nextimg = $nextrow['pic_id']; print('<a href=photos.php?cat_id='.$cat_id.'&thumb=full&pic_id='.$nextimg.'><img src="images/'.$location.$file_name.'" border="0"></a>'); } } } ?> Quote Link to comment Share on other sites More sharing options...
gevans Posted July 29, 2009 Share Posted July 29, 2009 $resultNxt = mysql_query("SELECT * FROM photo_img WHERE cat_id=$category AND pic_id > $pic_id LIMIT 1"); if (!resultNxt) { die("query failed: " . msql_error()); } while ($nextrow = mysql_fetch_array($resultNxt)) { $nextimg = $nextrow['pic_id']; print('<a href=photos.php?cat_id='.$cat_id.'&thumb=full&pic_id='.$nextimg.'><img src="images/'.$location.$file_name.'" border="0"></a>'); } You're relying on having a next image to display the current. When on the last image there isn't a next one... if $resultNxt returns no results you need to display the current image with no link (or a link to the first) Quote Link to comment Share on other sites More sharing options...
Guber-X Posted July 29, 2009 Author Share Posted July 29, 2009 okay, thnx. but sorry, i need someone to spell it out for me on this one i dont really know how its done? Quote Link to comment Share on other sites More sharing options...
gevans Posted July 29, 2009 Share Posted July 29, 2009 try this; <?php echo "<br /><br />"; $result3 = mysql_query("SELECT * FROM photo_img WHERE pic_id=$pic_id LIMIT 1"); if (!$result3) { die("query failed: " . msql_error()); } $result4 = mysql_query("SELECT * FROM photo_cat WHERE cat_id=$category ORDER by id LIMIT 1"); if (!$result4) { die("query failed: " . msql_error()); } while ($row = mysql_fetch_array($result4)) { list($id, $cat_name, $cat_id, $location) = $row; while ($row = mysql_fetch_array($result3)) { list($id, $pic_id, $file_name, $cat_id, $comment,) = $row; $resultNxt = mysql_query("SELECT * FROM photo_img WHERE cat_id=$category AND pic_id > $pic_id LIMIT 1"); if (!resultNxt) { die("query failed: " . msql_error()); } if(mysql_num_rows($resultNxt) == 0) { print('<img src="images/'.$location.$file_name.'" border="0">'); } else { while ($nextrow = mysql_fetch_array($resultNxt)) { $nextimg = $nextrow['pic_id']; print('<a href=photos.php?cat_id='.$cat_id.'&thumb=full&pic_id='.$nextimg.'><img src="images/'.$location.$file_name.'" border="0"></a>'); } } } } ?> Quote Link to comment Share on other sites More sharing options...
Guber-X Posted July 30, 2009 Author Share Posted July 30, 2009 whoa!... sweet that totally worked. i was gonna try and write that out a totally different way and it probably wouldnt have worked. thank you so much 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.