【发布时间】:2013-10-29 11:20:34
【问题描述】:
基于种姓、宗教、位置、性别、年龄,我需要从我的数据库中过滤数据,我该怎么做。
在 mysql 数据库中,我将宗教、性别、位置、年龄作为同一表中的单独列。
我用过的代码
$result=mysql_query("SELECT * FROM enquiry where location like '%$text%'and gender like'%$text1%' ")
or die("error");
$found=mysql_num_rows($result);
if($found>0){
while($row=mysql_fetch_array($result)){
//display of data
}
使用它,我可以使用一个关键字从一列中搜索数据...因为我是新手,请给我正确的方法来使用 php 解决这个问题。
【问题讨论】:
-
or someothercolumn like '%$text%'怎么样? -
我不明白你的问题...
-
或...
location REGEXP "text1|text2|text3"或location in ('text1','text2','text3') -
我从用户表单获取数据作为文本。我必须从位置为文本且性别为 text1 的数据库中选择数据,依此类推...@ gloomy.penguin