Click here to Skip to main content
15,937,602 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hey guys,

I'm pretty new to asp, know html well enough and some php. My latest project is one for my comic book collection. I've created a sql DB called 'Comics' with a table called 'Info'. I have a bunch of columns; Picture, Title, Issue, Grade, Signature, Serial, Publisher, Category, Box. These are in order from left to right and the pictures column is referring to images in a sub-folder.

What I want to be able to do is search for a comic Title, or Grade (.5 - 10.0) or Issue number, etc. and have all column for the matches appear on my search.asp page.

I tried using a response.write() line of code to display the contents below the blue column names, but the search comes up empty, no error messages (anymore, haha).

Any help is greatly appreciated. I have an example of one I made w/o a SQL DB, just plain ol' php and html, in that example there is a filter bar at the top for searching the corresponding column and you'll notice the whole row appears. I want the same function, but with my search bar at the top since it looks more purdy :)

Here's the link to the example with the tablefilter:

http://jumpace.atspace.co.uk/comics

And here is my code:

VB
<%
'check for a match
Set myRecordSet = Connect.Execute ("SELECT * FROM Info WHERE Title LIKE '%" & searchInput & "%'")
'Set myRecordSet = Connect.Execute ("SELECT * FROM Info WHERE Issue LIKE '%" & searchInput & "%'")
'Set myRecordSet = Connect.Execute ("SELECT * FROM Info WHERE Grade LIKE '%" & searchInput & "%'")
'Set myRecordSet = Connect.Execute ("SELECT * FROM Info WHERE Signature LIKE '%" & searchInput & "%'")
'Set myRecordSet = Connect.Execute ("SELECT * FROM Info WHERE Serial LIKE '%" & searchInput & "%'")
'Set myRecordSet = Connect.Execute ("SELECT * FROM Info WHERE Publisher LIKE '%" & searchInput & "%'")
'Set myRecordSet = Connect.Execute ("SELECT * FROM Info WHERE Category LIKE '%" & searchInput & "%'")
'Set myRecordSet = Connect.Execute ("SELECT * FROM Info WHERE Box LIKE '%" & searchInput & "%'")

'display the results
   do while not myRecordSet.EOF
   on error resume next
   response.write("<tr>" & "<td class=Comics align=center>" & aux & "<img src=images/" & aux & myRecordSet("Picture") & ".jpg>")
   response.write("<td class=Comics align=center>" & aux & myRecordSet("Title"))
   response.write("<td class=Comics align=center>" & aux & myRecordSet("Issue"))
   response.write("<td class=Comics align=center>" & aux & myRecordSet("Grade"))
   response.write("<td class=Comics align=center>" & aux & myRecordSet("Signature"))
   response.write("<td class=Comics align=center>" & aux & myRecordSet("Serial"))
   response.write("<td class=Comics align=center>" & aux & myRecordSet("Publisher"))
   response.write("<td class=Comics align=center>" & aux & myRecordSet("Category"))
   response.write("<td class=Comics align=center>" & aux & myRecordSet("Box") & "</tr>")
   myRecordSet.MoveNext %>
<% Loop %>
<% DbObj.Close 
SET DbObj = Nothing 
%>  



UPDATE: I got the ability to search any one of the columns, but not all of the columns...halp!

Also, if anyone can help me get alternating gray lines (#F4F4F4) that would be superb!

Thanks in advance for your time and help guys!


Jerome
Posted
Updated 7-Jul-12 9:14am
v2

1 solution

Use the OR clause[^] in your SQL statement.
SQL
SELECT * FROM Info WHERE Title LIKE '%" & searchInput & "%' OR Issue LIKE '%" & searchInput & "%'"
Add an OR clause for each of the columns.
 
Share this answer
 
Comments
jump_ace 8-Jul-12 1:10am    
That worked like a charm, thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900