SunQuest
           Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old January 21st, 2003, 11:51 PM
madhombre madhombre is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: WI
Posts: 247 madhombre User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
next and prev in sql

Hi, I was wondering if there was an easy way to handle the following.

I have a dyanmically created web site which flips through team members. I have next and prev buttons to flip. The order is based on name. Now I do have a drop down box which also selects and that is working, I know how to order by name in sql.

BUT for the buttons I want to use sql to get the nest item based on name ...

example
1.ted
2.bob
3.james

you are on james, the button for next would need to point to record 1 and the prev would need to point to 2.

can SQL do this if given 3.james???
or do I have to get the whole table and work it out myself. I am still a novice with sql.

Thanks, I hope I explained myself well enough

Reply With Quote
  #2  
Old January 22nd, 2003, 01:19 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: next and prev in sql

You'd need to work it out yourself...sql has no concept of previous and next links....

Reply With Quote
  #3  
Old January 22nd, 2003, 03:19 AM
madhombre madhombre is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: WI
Posts: 247 madhombre User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: next and prev in sql

I figured, what is the best way - added them to the database or calculate by grabbing the whole table?

Reply With Quote
  #4  
Old January 22nd, 2003, 08:01 AM
xs0 xs0 is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Ljubljana, Slovenia
Posts: 760 xs0 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: next and prev in sql

Well, you can almost do it with SQL. Something like this:
php Code:
Original - php Code
  1.  
  2. <?php
  3. // output the link
  4. echo "<a href="$PHP_SELF?current=$name&action=prev">Previous</a>";
  5.  
  6. // and then, after the click
  7. if ($_GET["action"]=="prev") {
  8.    $query="SELECT * FROM table WHERE name<"".$_GET["current"]."" ORDER BY name DESC LIMIT 1";
  9.    // do your stuff
  10. }

Reply With Quote
  #5  
Old January 23rd, 2003, 08:24 PM
madhombre madhombre is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: WI
Posts: 247 madhombre User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: next and prev in sql

will that work?

intersting concept, it should in theory

what the hey I will try it

Reply With Quote
  #6  
Old January 28th, 2003, 02:18 AM
madhombre madhombre is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: WI
Posts: 247 madhombre User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: next and prev in sql

it worked!

excellent work.

then, of course, I wanted to get fancy and introduce another variable into the equation as far as order goes, which failed completely so I had to work around but the main idea did work.

Thanks

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > next and prev in sql


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