Jump to content

[SOLVED] click image to goto next image


Guber-X

Recommended Posts

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>');

			}
			}

			}
?>

Link to comment
Share on other sites









$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)

Link to comment
Share on other sites

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>');
		}
	}
}
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.