PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 23rd, 2004, 07:06 PM
vicpal25 vicpal25 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 1 vicpal25 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Talking 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';");
$sqlcountmysql_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!

Reply With Quote
  #2  
Old September 24th, 2004, 04:56 AM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 6
Your problem lies in this section -

PHP Code:
<?
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>


After the line where you echo the <a> tag you need to close php ?> so it can just write out the image, at the moment it is probably giving you some errors as well as not working since it won't be able to parse that line.

-KM-

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > PHP <previous> and <next> link problem??


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT