Hi there,
If you look at the code below, you will see that I am using a template
in order to display some photos on my website.
I also have "previous" and "next" buttons/link which increment the
PhotoId in my table so you can easily navigate.
I only have 35 rows in this particular table, but when you get to the
35th picture, clicking on next takes you to 36 which does not exist.
Same when you are on id 1 and click previous.
I am trying to prevent this with my poor excuse of an "if" statement,
but it doesn't seem to do the trick.
Please advise.
Regards,
Ciprian
<html>
<head>
<?php
$db = mysql_connect(" localhost","use r","pass");
mysql_select_db ("mydb",$db) ;
$request = "SELECT * FROM photos WHERE PhotoId=".$Phot oId;
$result = mysql_query ($request,$db);
$photos =mysql_fetch_ob ject($result);
mysql_free_resu lt($result);
?>
<title>Photos 2004 - <?php echo $photos->PhotoDesc ?> </title>
</head>
<body>
<table width="600" border="0" cellspacing="0" cellpadding="2"
align="center">
<tr>
<td align="center">
<img src="<?php echo $photos->PhotoFileNam e ?>" alt="<?php echo
$photos->PhotoDesc ?>" title="<?php echo $photos->PhotoDesc ?>"
border="0">
</td>
</tr>
<tr>
<td align='center'>
<?php echo $photos->PhotoDesc ?>
</td>
</tr>
<tr>
<td align='center'>
<a href='index.php ?PhotoId=<?php echo $photos->PhotoId-1
?>'>Previous</a> | <a href="index.php ?PhotoId=1">Ind ex</a> | <a
href='index.php ?PhotoId=<?php echo $photos->PhotoId+1 ?>'>Next</a>
</td>
</tr>
</table>
<?php
if (&PhotoId > 35)
print "1";
?>
</body>
</html>