search library system in asp

A

amoona

Hi…

I’m doing a search page form my work for their library. Since
this is the first time I work with ASP I’m facing some problems.

Each library item has different search data, I was able to build but
I’m stuck at when the user chooses books for e.g it refreshes
the page and the combo box goes to the first item.while I want it to
stay on books.
The second problem is that I need a code for displaying the specific
table chosen by the user from the first combo.

I’ve done it by an if statement but it didn’t work…
This is the code I have come up with:



<html>
<body bgcolor="#FFFFFF" text="#000000" >

<%

Dim strURL
Dim cnnSearch
Dim rstSearch
Dim strDBPath
Dim strSQL
Dim strSearch

strURL = Request.ServerVariables("URL")

strSearch = Request.QueryString("search")
strSearch = Replace(strSearch, "'", "''")
y=request("mymenu")

%>

<b>
<form name="form1" method="get" action="test.asp">
<font color="#32B0AF" size="2">
Search in:
</font>
<select name="mymenu" onchange="document.form1.submit()">
<option value="0" selected>---Select---</option>
<option value="1">Book</option>
<option value="2">Magazine</option>
<option value="3">Legal Gazzete</option>
<option value="4">Science Paper</option>
<option value="5">Video</option>
<option value="6">Clipping</option>
</select>


<% if y>0 then %>
<font color="#32B0AF" size="2">
Search By:
</font>

<%Select Case y
Case "1"
%>
<select name="sub" >
<option value="0" selected>---Select---</option>
<option value="title">Title</option>
<option value="author">Author</option>
<option value="topic">Topic</option>
<option value="keyword">Keyword</option>
</select>

<% Case "2"%>
<select name="sub">
<option value="0" selected>---Select---</option>
<option value="name">Name</option>
<option value="title">Title</option>
</select>

<% Case "3"%>
<select name="sub">
<option value="0" selected>---Select---</option>
<option value="title">Title</option>
</select>

<% Case "4"%>
<select name="sub">
<option value="0" selected>---Select---</option>
<option value="title">Title</option>
<option value="author">Author</option>
</select>

<% Case "5" %>
<select name="sub">
<option value="0" selected>---Select---</option>
<option value="title">Title Keyword</option>
</select>


<% Case "6" %>
<select name="sub">
<option value="0" selected>---Select---</option>
<option value="title">Title Keyword</option>
</select>
<%Case Else

End Select%>

<input type="text" name="search">
<input type="submit" value="Search">

<% end if %>

</p>

<%
If strSearch <> "" Then

strDBPath = Server.MapPath("User Library system.bak")

Set cnnSearch = Server.CreateObject("ADODB.Connection")

cnnSearch.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Inetpub\wwwroot\User Library
system.bak;" & _
"Jet OLEDB:System
Database=C:\Inetpub\wwwroot\Secured.mdw;", _
"staff", "envr"

'if(y=1) then
strSQL = "SELECT bookid, title, topic " _
& "FROM books " _
& "WHERE title LIKE '%" & Replace(strSearch, "'", "''") & "%' order
by bookid ;"
'else if (y=2) then
'strSQL = "SELECT magazineid,name,title " _
'& "FROM Magazine " _
'& "WHERE name LIKE '%" & Replace(strSearch, "'", "''") & "%'
order by magazineid ;"
'end if

Set rstSearch = cnnSearch.Execute(strSQL)
%>

<table border="1">
<TR><TH>Book Id</th> <th>Title</th> <th>Topic</th></tr>
<%
Do While Not rstSearch.EOF
%>
<tr>
<td><%= rstSearch.Fields("bookid").Value %> </td>
<td><%= rstSearch.Fields("title").Value %> </td>
<td><%= rstSearch.Fields("topic").Value %> </td>
</tr>
<%
rstSearch.MoveNext
Loop
%>
</table>
<%
rstSearch.Close
Set rstSearch = Nothing
cnnSearch.Close
Set cnnSearch = Nothing
End If
%>
</body>
</html>






Thanxxxxx for ur help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,192
Latest member
KalaReid2

Latest Threads

Top