Opgradere denne søgemaskine...
Jeg har fået lavet denne søgemaskine i ASP, det er til et cd-kartotek. Hvordan kan man lave den så man kan søge på flere ord og hvis man ikke udfylder noget i felterne så viser den ingenting istedet for alt hvad der er i databasen.<%
CDnummer = Trim(Request.Form(\"CDnummer\"))
If Len(CDnummer) = 0 Then
Else
CDnummer = Replace(CDnummer,\"\'\",\"\'\'\")
End If
Nummer = Trim(Request.Form(\"nummer\"))
If Len(Nummer) = 0 Then
Else
Nummer = Replace(Nummer,\"\'\",\"\'\'\")
End If
Kunster = Trim(Request.Form(\"Kunster\"))
If Len(Kunster) = 0 Then
Else
Kunster = Replace(Kunster,\"\'\",\"\'\'\")
End If
Sang = Trim(Request.Form(\"Sang\"))
If Len(Sang) = 0 Then
Else
Sang = Replace(Sang,\"\'\",\"\'\'\")
End If
SQL = \"SELECT CDnummer, Nummer, Kunster, Sang FROM Kartotek WHERE\"
SQL = SQL & \" (CDNummer LIKE \'%\" & CDnummer & \"%\')\"
SQL = SQL & \" and (Nummer LIKE \'%\" & Nummer & \"%\')\"
SQL = SQL & \" and (Kunster LIKE \'%\" & Kunster & \"%\')\"
SQL = SQL & \" and (Sang LIKE \'%\" & Sang & \"%\')\"
DSN = \"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\"&Server.MapPath(\"database.mdb\")
Set Connection = Server.CreateObject(\"ADODB.Connection\")
Connection.Open DSN
Set RS = Connection.Execute(SQL)
If Not (RS.BOF Or RS.EOF) Then
Response.Write \" <table cellpadding=\"\"5\"\" cellspacing=\"\"0\"\">\"
Response.Write \" <tr>\"
Response.Write \" <td width=\"\"200\"\"><img src=\"\"interface/images/thump_cdnummer.gif\"\" width=\"\"164\"\" height=\"\"10\"\"></td>\"
Response.Write \" <td width=\"\"200\"\"><img src=\"\"interface/images/thump_nummer.gif\"\" width=\"\"120\"\" height=\"\"10\"\"></td>\"
Response.Write \" <td width=\"\"200\"\"><img src=\"\"interface/images/thump_kunster.gif\"\" width=\"\"135\"\" height=\"\"10\"\"></td>\"
Response.Write \" <td width=\"\"200\"\"><img src=\"\"interface/images/thump_sang.gif\"\" width=\"\"80\"\" height=\"\"10\"\"></td>\"
Response.Write \" </tr>\"
Response.Write \" <tr>\"
Response.Write \" <td colspan=\"\"4\"\"><img src=\"\"interface/images/linje.gif\"\" width=\"\"100%\"\" height=\"\"1\"\"></td>\"
Response.Write \" </tr>\"
Response.Write \" <tr>\"
Do While Not RS.EOF
Response.Write \" <tr>\"
Response.Write \" <td width=\"\"200\"\">\" & RS(\"CDnummer\") & \"</td>\"
Response.Write \" <td width=\"\"200\"\">\" & RS(\"Nummer\") & \"</td>\"
Response.Write \" <td width=\"\"200\"\">\" & RS(\"Kunster\") & \"</td>\"
Response.Write \" <td width=\"\"200\"\">\" & RS(\"Sang\") & \"</td>\"
Response.Write \" </tr>\"
RS.MoveNext
Loop
Response.Write \" </table>\"
Else
Response.Write \"Der kunne desværre ikke findes noget i databasen!\"
End If
Connection.Close
Set Connection = Nothing
%>