|
-
Mar 31st, 2003, 11:00 AM
#1
Thread Starter
New Member
How would i...
I want to create a search box, where users can enter a name, and it searches the database and displays. the form tag is
<form runat="server" name="form1" method="post" action="search2.asp">
in search2.asp i put the SQL as
Code:
SQLString = "SELECT * FROM Clients WHERE Request.Form("surname")=surname ORDER BY clientID ASC "
Am i doing something really silly and wrong?
Plus, in future i'd like to create a thing, where the user can select what field he'd like to search in aswell, and advice?
Thanks in advance
Last edited by Bubbles_; Mar 31st, 2003 at 11:06 AM.
-
Mar 31st, 2003, 11:06 AM
#2
Frenzied Member
Should be: (I thinnk)
Code:
SQLString = "SELECT * FROM Clients WHERE surname ='" & Request.Form("username") & "' ORDER BY clientID ASC "
-
Mar 31st, 2003, 11:11 AM
#3
Thread Starter
New Member
Thanks a lot !!
Works
-
Mar 31st, 2003, 11:21 AM
#4
Thread Starter
New Member
the next bit...
I have this on search.asp
Code:
<select name="searchtype">
<option value="ClientID">ClientID
<option value="surname">Surname
<option value="age" selected>Age
<option value="Email">Email
</select>
what would you type in search2.asp so that it selects that field, something like this?
SQLString = "SELECT * FROM "' & Request.form("searchtype") & "' WHERE surname ='" & Request.Form("field") & "' ORDER BY clientID ASC "
-
Mar 31st, 2003, 12:42 PM
#5
Frenzied Member
NO,
it's:
Code:
SQLString = "SELECT * FROM Clients WHERE [" & Request.form("searchtype") & "]='" & Request.Form("field") & "' ORDER BY clientID ASC "
if age is a numeric field then remove single quotes from sql statement. Same for ClientID.
It's always:
SELECT fields_to_select
FROM table_name
WHERE field_name = field_value
ORDER BY field_name ASC (DESC)
-
Mar 31st, 2003, 04:06 PM
#6
Thread Starter
New Member
you sir...are a god !

watch this space for more silly problems
-
Mar 31st, 2003, 04:18 PM
#7
Frenzied Member
Can't wait....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|