|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Hey,
I'm trying to use information that a user enters into an HTML form to search a database. For example, if a user clicks on a check box stating their interests are 'holidays' then this information needs to be used to search the database for entries that match, ie the entry has a category that states it is about holidays. The entries in the database are linked to pictures that will then be loaded onto a website. I need to use ASP for this as well but have got completely stuck and don't know where to start, therefore any help is greatly appreciated. Thanks |
|
#2
|
||||
|
||||
|
Quite a lot to ask really, don't you think?
To start with, you need a html form that looks like this Code:
<form method="post"> <input type="checkbox" name="searchchoice" value="holidays" /> <input type="checkbox" name="searchchoice" value="cars" /> <input type="checkbox" name="searchchoice" value="monkeys" /> </form> and an asp page that does something like..... Code:
dim c, r, s
set c = createobject("adodb.connection")
set r = createobject("adodb.recordset")
c.connectionstring = (connectionstring needed here)
c.provider = "Microsoft.Jet.OleDB.4.0"
c.open
s = "select * from wherever where something like '" & request.form("searchchoice") & "'"
Set r = c.execute(s)
while r.eof = false
response.write r.fields(0) & "<br>"
response.write r.fields(1) & "<br>"
response.write r.fields(2) & "<br>"
r.movenext
wend
you'd need something in place that makes sure they only select one choice, otherwise it will screw the SQL statement up....... If you selected "Holidays" then the SQL would be select * from wherever where something like 'holidays' and if the other choices are picked, holidays would be replaced with the respective choice. then a simple loop will write out all rows that match the SQL statement. I'd recommend a book on ASP! By the way, that won't work by itself but it demonstrates what you need to do, in a crude way.
__________________
_______________ Matt Last edited by Utopia : February 24th, 2003 at 09:10 AM. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Using information from a form to search a database |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|