搜索任何列,返回查询列的整个行 [英] Search Any Column, Return Entire Row Of Queried Column

查看:86
本文介绍了搜索任何列,返回查询列的整个行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我对ASP非常陌生,对HTML足够了解,并且对PHP也很了解.我最新的项目是我的漫画集.我已经创建了一个名为"Comics"的SQL数据库,并带有一个名为"Info"的表.我有一堆专栏;图片,标题,问题,等级,签名,序列号,发布者,类别,框.这些按从左到右的顺序排列,并且图片"列引用子文件夹中的图像.

我想要做的是搜索喜剧标题,年级(.5-10.0)或发行编号等,并将所有匹配项列显示在我的search.asp页上.

我尝试使用response.write()行代码来显示蓝色列名称下方的内容,但是搜索结果为空,没有错误消息(而且,哈哈).

任何帮助是极大的赞赏.我有一个示例,我没有使用SQL DB,只是普通的php和html,在该示例中,顶部有一个过滤器栏,用于搜索相应的列,您会注意到整行都出现了.我想要相同的功能,但搜索栏位于顶部,因为它看起来更纯净:)

这是带有tablefilter的示例的链接:

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

这是我的代码:

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:

<%
'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 
%>  




更新:我可以搜索任何一列,但不能搜索所有列...暂停!

另外,如果有人可以帮助我获得交替的灰线(#F4F4F4),那就太好了!

在此先感谢您的宝贵时间和帮助!!


Jerome




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

推荐答案

使用 OR子句 [<您的SQL语句中的href ="http://www.w3schools.com/sql/sql_and_or.asp" target ="_ blank" title ="New Window"> ^ ].
Use the OR clause[^] in your SQL statement.
SELECT * FROM Info WHERE Title LIKE '%" & searchInput & "%' OR Issue LIKE '%" & searchInput & "%'"

为每个列添加一个OR子句.

Add an OR clause for each of the columns.


这篇关于搜索任何列,返回查询列的整个行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆