
September 23rd, 2004, 07:06 PM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
PHP <previous> and <next> link problem??
Hello, I am working on a gallery of my work, and I am using dynamic next and previous buttons. My problem is at the <previous> button/link. I got the <next> to work just fine but the <previous> just goes down one level. Please someone give me some advice on how to take care of this little bug. Thanks! any help is appreciated.
PHP Code:
if(isset($_GET['key'])) { $key = $_GET['key']; //database connection stuff $connect=mysql_connect ($mysql_server, $mysql_user, $mysql_password) or die("cannot make connection"); $dbselect=mysql_select_db (showcase) or die("cannot select database"); //sql statments $result = mysql_query("SELECT `title`,`description`, `image` FROM `gd-gallery` WHERE `key` = '$key';"); $sqlcount= mysql_query("SELECT COUNT(*) FROM `gd-gallery`;"); //fetch results into variables $count (counts records from database) and $row will fetch results into an array $countrecords = mysql_result($sqlcount,0); $row=mysql_fetch_row($result); $title= $row[0]; $description= $row[1]; $image= $row[2]; } echo $countrecords; if ($key >= $countrecords ) { //do nothing } else { echo "a is smaller than b"; $key= $key + 1; } echo '<a href="/showcase/gd-showcase.php?key='.urlencode($key).'">'; ?> <img src="/images/nav-next.gif" alt="Next" /> </a> </div> <? if ($key < 0 ) { //do nothing } else { echo "key is smaller than count"; $key--; echo $key; } echo '<a href="/showcase/gd-showcase.php?key='.urlencode($key).'">'; <img src="/images/nav-previous.gif" alt="Previous" /> </a>
Thanks!
|