search library system in asp

Discussion in 'ASP General' started by amoona, Aug 13, 2003.

  1. amoona

    amoona Guest

    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
    amoona, Aug 13, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TGFrc2htaSBOYXJheWFuYW4uUg==?=

    Google search result like site search!! How?

    =?Utf-8?B?TGFrc2htaSBOYXJheWFuYW4uUg==?=, May 5, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    644
    Lucas Tam
    May 6, 2005
  2. Andy
    Replies:
    1
    Views:
    337
    Jack Klein
    Nov 25, 2003
  3. Anand Pillai

    String search vs regexp search

    Anand Pillai, Oct 12, 2003, in forum: Python
    Replies:
    10
    Views:
    570
    Anand Pillai
    Oct 15, 2003
  4. Abby Lee
    Replies:
    5
    Views:
    366
    Abby Lee
    Aug 2, 2004
  5. Rafael Nenninger

    File System Search on an asp file yields not results

    Rafael Nenninger, Nov 1, 2004, in forum: ASP General
    Replies:
    2
    Views:
    181
    Aaron [SQL Server MVP]
    Nov 1, 2004
Loading...

Share This Page