如何创建高级搜索 [英] How to create an advance search

查看:66
本文介绍了如何创建高级搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我有一个任务来创建一个简单的网站,并且想对我的网站进行高级搜索.

基本上,我有一个名为personalinfo的表,该表由姓名,年龄,性别,地址和电话号码组成.

我想做的是创建一个带有五个文本框的高级搜索,分别是:姓名,年龄,性别,地址和电话号码.

因此,基本上,我的高级搜索所要做的就是它允许用户使用许多查询进行搜索.

假设用户要在personalinfo表中查找年龄= 22且性别为女性的人.

因此,他们输入的内容将是用于输入名称的文本框为空白,使用20填充文本框的年龄,使用男性填充文本框的性别,将地址和电话号码文本框保留为空白.

如何编码?

目前,我正在考虑使用很多if,但是我认为效率不高.

任何帮助将不胜感激.

预先谢谢您..

So, I have an assignment to create a simple website and I want to create an advance search to my site.

Basically I have a table called personalinfo that is consist of name, age, gender, address, and phone number.

What I''m trying to do is creating an advance search with five textboxes for input which are; name, age, gender, address, and phone number.

So, basically what my advance search do is it allows user to search by using a number of queries.

Let''s say, user want to find in personalinfo table where age = 22 and gender is female.

So, what their input will be leave the textbox for inputting name blank, textbox age filled with 20, textbox gender filled with male, and leave the address and phone number textbox blank.

How to code it?

Currently I''m thinking of using lots of if, but I think it is not efficient.

Any helps will be really appreciated.

Thank you in advance..

推荐答案

我首先要对单个字段进行搜索,然后从那里开始.你试过什么了?如果使用的是SQL Server,则需要带有参数的存储过程,并将输入参数用作where子句的一部分.

顺便说一句,除非是您的作业的特定组成部分,否则将"Age"存储在表中通常是不好的,因为它仅在某个时间点是正确的.现在您的年龄与明年的年龄不一样.通常最好存储出生日期,然后可以根据需要计算年龄...
I would start by making search work for a single field, and building up from there. What have you tried so far? If you are using SQL Server, you would want a stored procedure with parameters, using the input parameters as part of the where clause.

As an aside, unless it''s specifically part of your assignment, storing "Age" in a table is generally bad, as it''s only true at a point in time. Your age now isn''t the same as your age next year... You are generally better to store the date of birth, then you can calculate the age if necessary...


你好....

尝试访问 [
Hi there..

Try visiting this[^] link.. It may help you a lot..

all the best..


这篇关于如何创建高级搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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