-
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
-
Should be: (I thinnk)
Code:
SQLString = "SELECT * FROM Clients WHERE surname ='" & Request.Form("username") & "' ORDER BY clientID ASC "
-
-
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 "
-
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)
-
you sir...are a god !
:)
watch this space for more silly problems :)
-