|
Hi everyone, i want to enter a value into a text field, then click my submit button, i want this then to generate the asp code which should then search the database. for example i enter a part e.g. seal, then i press submit it then searches the database for seal then it displays this in another html page. Does anyone know how to do this, any help would be much appreciated. I know in my asp page i will need
<%
dim rsPru, adoPruCon, adoPruCmd, sPruDB, sSQL
sPruDB="Provider=Microsoft.Jet.OLEDB.4.0; " & "Data Source=" & server.MapPath("PRU.mdb")
set adoPruCon= Server.CreateObject("ADODB.Connection")
adoPruCon.Open sPruDB
set rsPru=server.createObject("ADODB.Recordset")
sSQL = "SELECT * FROM T_Parts"
rsPru.open sSQL, adoPruCon, adOpenDynamic, adLockOptimistic, adCmdText
%>
<%
if rsPru.EOF then
Response.Write "No records returned, please search again"
else
Response.Write "<TABLE>"
while not rsPru.EOF
Response.Write "<hr>"
Response.Write "<b>PART: </b>" & rsPru("CH_Part Name") & "<b> / TYPE: </b>" & rsPru("CH_Part Description") & "<br>"
Response.Write "<b>REF: </b>" & rsPru("CH_Refernce") & "<b> / PRICE: £</b>" & rsPru("CH_Price") & "<br>"
Response.Write "<br>"
rsPru.MoveNext
wend
end if
%>
what would i need to put in the html?.
But how do i write it to a html page and display, but also how can i keep it there for when i want to add another. display all the parts the user as requested etc.
|
|
|
I am not sure of what exactly u r asking. Could u clarify please?
|
|
|
I agree with Marx I am not sure exactly what you are looking for. From the code you listed you are going to list all of the records in the table...do you want to just find a specific record?
|
|
|
To answer part of your question--that is how to only show results matching the text entered by the user in the HTML form: Simply have a textbox in a form. Submit that form to your ASP page (similar to the ASP you listed). Have that page test the value of the textbox -- if the length is greater than 0, then add "where CH_PARTNAME like '%" & Request.Form("part_search") & "%'" |
| to your query. Then your SQL query will only return the matching parts.
|
|
|
|
|
|
|
|
|
|