Weiter mit id+1 bzw nächste id

Lösung:
So funktioniert es

PHP:
<?PHP
$sql = "SELECT * FROM `test` WHERE `id` = '".$_GET['id']."' LIMIT 1";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
	{
		echo '<img src="'.$row['url'].$row['pic'].'" border="0">';
	}


//Tiefste ID bzw. zurück
$sql = "SELECT * FROM `test` ORDER BY `id` ASC LIMIT 1";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
	{
		$low = $row['id'];
	}
if($_GET['id'] == $low)
	{
		echo 'zurück | ';
	}
else
	{
		$sql = "SELECT * FROM `test` WHERE `id` < '".$_GET['id']."' ORDER BY `id` DESC LIMIT 1";
		$result = mysql_query($sql);
		while($row = mysql_fetch_array($result))
			{
				echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$row['id'].'">zurück</a> | ';
			}
	}
//Höchste ID bzw. weiter
$sql = "SELECT * FROM `test` ORDER BY `id` DESC LIMIT 1";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
	{
		$high = $row['id'];
	}
if($_GET['id'] == $high)
	{
		echo 'weiter';
	}
else
	{
		$sql = "SELECT * FROM `test` WHERE `id` >  '".$_GET['id']."' ORDER BY `id` ASC LIMIT 1";
		$result = mysql_query($sql);
		while($row = mysql_fetch_array($result))
			{
				echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$row['id'].'">weiter</a>';
			}
	}
?>
 
Zurück