PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

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 Dev Shed Forums Sponsor:
  #1  
Old February 17th, 2000, 10:32 PM
Martijn Martijn is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 1999
Posts: 14 Martijn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i have some ideas to make a previous and next
buttons from a query but I can't get them to work.

I have:

$id = 75

SELECT id,name,cat FROM $table WHERE cat=$cat

result=

12 namex dog
67 namea dog
56 nameb dog
75 namef dog
77 namet dog
99 namer dog

Can I filter the previous and next id in the result from
my $id???

so you get:

56 nameb dog
75 namef dog
77 namet dog

If not, how can I make these 2 loops:

A)
$id++
result = nothing (id=76)
$id++
result = 77 namet dog
stop

b)
$id--
result = nothing (id=74)
$id--
result = nothing (id=73)
$id--
result = nothing (id=72)

---
$id--
result = nothing (id=57)
$id--
result = 56 nameb dog
stop


Thanx allot
Martijn

Reply With Quote
  #2  
Old February 18th, 2000, 04:15 PM
oh_boy oh_boy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Location: The Netherlands
Posts: 3 oh_boy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Beste Martijn,

there is perhaps a different solution, I'm not sure you like it. URL
But is not difficult to find the next/prev id using a new query.

For example, if you want to find the previous id, simply execute following query:

SELECT max(id) FROM $table WHERE (id<$id)
The result is 67 ($id=75 as in your example), and is the id of the previous record.

For the next id, the query is:
SELECT min(id) FROM $table WHERE (id>$id)

With regards,

Roald

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > previous and next...

Developer Shed Advertisers and Affiliates



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 | 
  
 


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

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap