| Author |
Topic Search Topic Options
|
Scotty32
Moderator Group
Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
|
Post Options
Thanks(0)
Quote Reply
Topic: how can i skip to the next user? Posted: 11 April 2003 at 3:10am |
does anyone know the best way i can put a "next" button on a page - to show the next set of details - but not by ID but by the last name
so ya can skip to the next person alphabetaicly?
|
 |
pmormr
Senior Member
Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
|
Post Options
Thanks(0)
Quote Reply
Posted: 11 April 2003 at 2:54pm |
When you open the recordset use the SQL statement
SELECT * FROM yourfield FROM yourtable ORDER BY yourfield asc
not totally positive on my coding but you should get the basic idea... this will order 'yourfield' from 'yourtable' into ascending alphabetical order. now you can use the following HTML statement to move to the next name in the list.
<a href="<%rs.movenext%>">Next name</a>
now, this tells the computer to move to the next record and since they're ordered in alphabetical it moves to the next record. This link needs to be on the same page as the opening calls for the database and sql statement. Something like this
'open your database 'recordset opening call 'html beginning 'your link 'html ending
hope i helped...
Paul Morgan Webmaster
|
|
|
 |
Scotty32
Moderator Group
Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
|
Post Options
Thanks(0)
Quote Reply
Posted: 14 April 2003 at 4:55am |
hi - thanks
umm could ya explain that a lil better cose i dont quite get it
i tryed sum things but with out success
do i put "SELECT * FROM table WHERE field = string ORDER BY lastname" ???
or not
could i please have sum example code?
(thanks for the help)
|
 |
pmormr
Senior Member
Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
|
Post Options
Thanks(0)
Quote Reply
Posted: 14 April 2003 at 8:50am |
no problem- the only problem with using a "WHERE" clause is that it only selects what it equals. For example: If you have several records, lastnames (to make it easy) 5, 4, 3, 2, and 1, and you use the line "SELECT * FROM yourtable WHERE lastname = 5" then it will only select 5. My suggestion, drop the where clause and only use select and order by. Try this,
"SELECT * FROM yourtable ORDER BY lastname"
then use the link i posted before to move to the next record.
Paul Morgan
|
|
|
 |
Scotty32
Moderator Group
Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
|
Post Options
Thanks(0)
Quote Reply
Posted: 14 April 2003 at 8:51am |
|
oh, well how will i know which is the next record then?
|
 |
pmormr
Senior Member
Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
|
Post Options
Thanks(0)
Quote Reply
Posted: 14 April 2003 at 8:53am |
|
because there ordered in alphabetical order according to their lastnames. Try it and see if it works.
|
|
|
 |
Scotty32
Moderator Group
Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
|
Post Options
Thanks(0)
Quote Reply
Posted: 14 April 2003 at 8:54am |
yeah but i mean, say am on record number 5 how will i know i wanna go to number 6? cose it wont know am on record 5? will it?
|
 |
pmormr
Senior Member
Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
|
Post Options
Thanks(0)
Quote Reply
Posted: 14 April 2003 at 9:01am |
when you select the fields and use a where clause it only selects what you specify in the where clause . for example: you have a table: with one field called 'I' (remember i'm making it simple) the values of i are 1, 2, 3, 4, 5, 6, 7, and 8. if you only select 5 then the computer doesn't worry about 1, 2, 3, 4, 6, 7, and 8. When open up a recordset your basically telling the computer with a WHERE clause that you only need 5. When you say 'rs.movenext' then you hit EOF and you get a falure. If it was imperitive that you start on 5 then you would say:
"SELECT * FROM yourtable" rs.movefirst loop = 5 While loop > 0 rs.movenext Wend
this would take your record pointer and place it on the fifth one in order.
Edited by pmormr
|
|
|
 |