OutFront Forums
     Home    Register     Search      Help      Login    

Sponsors
Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax
Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.
Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Follow Us
On Facebook
On Twitter
RSS
Via Email

Recent Posts
Todays Posts
Most Active posts
Posts since last visit
My Recent Posts
Mark posts read

 

Database results criteria/ order help

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP, PHP, and Database >> Database results criteria/ order help
Page: [1]
 
 
webgyrl

 

Posts: 52
Joined: 2/9/2009
Status: offline

 
Database results criteria/ order help - 5/22/2009 13:44:55   
I have visited sites where once your search result appears you can click to show the order you want them to appear in..i.e order by date, order by low price to high price etc...how can i do this with my site using access and frontpage so my users can select what order they want their results to appear in?

< Message edited by webgyrl -- 5/22/2009 13:50:31 >
TexasWebDevelopers

 

Posts: 761
Joined: 2/22/2002
From: Dallas, TX
Status: offline

 
RE: Database results criteria/ oder help - 5/22/2009 13:58:53   
Call your data into a table.
At the top of each column make a hyperlink that will be your querystring.
<a href="yourpage.asp?xorder=fname">Order by</a>
<a href="yourpage?xorder=lname">Order by</a>
<a href="yourpage?xorder=address">Order by</a>

At the top of the page put code to capture the query string information and to give the default "ORDER BY" when the user first lands on the page (in this case it is lname).
The variable is xorder and the value is the field name (like fname, lname, address).

<%
DIM xorder
xorder=request.querystring("xorder")
If request.querystring("xorder")="" then
xorder="lname"
end if
%>

Then stick the field you want to ORDER BY into the sql statement:

<% 'CREATE/OPEN RECORDSET
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "SELECT * FROM [table_name] ORDER BY " & xorder & " ASC"
rs.Open sql, objConnect, adOpenDynamic, adLockOptimistic
%>


<table>
<tr>
<td><a href="yourpage.asp?xorder=fname">Order by</a></td>
<td><a href="yourpage?xorder=lname">Order by</a></td>
<td><a href="yourpage?xorder=address">Order by</a></td>
</tr>
loop and write out your results:
<%
rs.MoveFirst
Do While Not rs.EOF
%>
<tr>
<td><%=rs.Fields("fname").Value)%></td>
<td><%=rs.Fields("lname").Value)%></td>
<td><%=rs.Fields("address").Value)%></td>
</tr>
<%
rs.MoveNext
Loop

rs.Close
Set rs= Nothing
%>
</table>

_____________________________

:)

Follow us on TWITTER

(in reply to webgyrl)
Page:   [1]

All Forums >> Web Development >> ASP, PHP, and Database >> Database results criteria/ order help
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts