Forums
This topic is locked
Changing DB Order
Posted 02 Dec 2001 07:22:22
1
has voted
02 Dec 2001 07:22:22 Mark McCarthy posted:
I'm very new to all this and am trying to get a backend news page to update a DB in the following manner.I have both up and down buttons which I want to use to change the order in which the news item appears in the DB(unique key: newsID).
Each item is shown like:
|-------------------------------------------------|
| news date | news name | up / dn / edit |
|-------------------------------------------------|
| news date | news name | up / dn / edit |
|-------------------------------------------------|
The up / dn buttons are what I want to use to change the newsID.
I'm sure there's probably a simple code snippet I apply to the form buttons(up/dn), but I'm not sure what that is. do you?
thanks in advance for your help.
Edited by - NEWflavour on 02 Dec 2001 16:49:28
Replies
Replied 02 Jan 2002 20:43:17
02 Jan 2002 20:43:17 Tolu Ayoola replied:
alright, i know this kinda violates UD's scripting but this is how i did mine
if the up/down is a button or list menu, assign the value of up to ASC and down to DESC. Then request the value to order the db.
For instance,
<%
Dim how
how = Request.QueryString("order"
If (how <> "" then
stg = Request.QueryString("order"
Else
how = "ASC" ' <b><<-- default order is ascending
</b>
End If
%>
<%
set allmembers = Server.CreateObject("ADODB.Recordset"
allmembers.ActiveConnection = MM_nsa_STRING
allmembers.Source = "SELECT * FROM Members ORDER BY " + how <b>'<<<--This is how the db would be read </b>
allmembers.CursorType = 0
allmembers.CursorLocation = 2
allmembers.LockType = 3
allmembers.Open()
allmembers_numRows = 0
%>
did that help?
The initial fright of failure is the beginning of failure itself -Tolu
Edited by - dloverinu on 02 Jan 2002 20:44:15
Edited by - dloverinu on 02 Jan 2002 20:45:05
Edited by - dloverinu on 02 Jan 2002 20:46:25
if the up/down is a button or list menu, assign the value of up to ASC and down to DESC. Then request the value to order the db.
For instance,
<%
Dim how
how = Request.QueryString("order"
If (how <> "" then
stg = Request.QueryString("order"
Else
how = "ASC" ' <b><<-- default order is ascending
</b>
End If
%>
<%
set allmembers = Server.CreateObject("ADODB.Recordset"
allmembers.ActiveConnection = MM_nsa_STRING
allmembers.Source = "SELECT * FROM Members ORDER BY " + how <b>'<<<--This is how the db would be read </b>
allmembers.CursorType = 0
allmembers.CursorLocation = 2
allmembers.LockType = 3
allmembers.Open()
allmembers_numRows = 0
%>
did that help?
The initial fright of failure is the beginning of failure itself -Tolu
Edited by - dloverinu on 02 Jan 2002 20:44:15
Edited by - dloverinu on 02 Jan 2002 20:45:05
Edited by - dloverinu on 02 Jan 2002 20:46:25