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:
  #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: 4
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: 26
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: 4
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: 4
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: 4
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: 4
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




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

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


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.


© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek