过滤多个字段的搜索 [英] filter search across multiple fields

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

问题描述

我正在创建一个网站公司女士。



基本上我想要的是用户可以按名称,年龄,身高,体重,城市等过滤结果。 。



例如,如果他们选择按名称过滤并写下希拉里的名字,显示所有打电话给希拉里的女性,但是名字,如果想按姓名和写下纽约市,然后展示居住在纽约的所有希拉里,如果按名称和城市过滤高度1.65英寸,那么显示所有生活在纽约的希拉里,高1.65英寸。



如果您只想在25岁时过滤,只出现在25岁以上的所有人。





我留下一些代码,我不能在那里移动









I am creating a website company ladies.

Basically what I want is that users can filter results by name, age, height, weight, city, etc..

example if they choose filter by name and write the name of hillary, display all the women who call hillary, but the name and if want to filter by name and write new york city and then display all the hillary living in new york, and if filtered by name and city more height 1.65 inches, then display all the hillary living in new york and measure 1.65 inches tall.

And if you want to filter only by age 25, appearing only all who are 25 years of age.


I leave some codes that I have, I can not move over there




<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<table>
    <tr>
        <td>name:</td>
        <td><input type="text" name="name" /></td>
    </tr>
    <tr>
        <td>mail:</td>
        <td><input type="text" name="mail" /></td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td><input type="submit" name="submit" value="Search" /></td>
    </tr>
</table>
</form>






<?php

$con = mysql_connect("localhost","user","password");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }



mysql_select_db("database", $con);











/*

require_once "common.php";*/





if(isset($_POST['submit'])) {



    $Nombre = $_POST['name'];

    $Email = $_POST['mail'];



    if($Nombre != '' && $Email != '') {

         $conditions = "name LIKE '%".mysql_real_escape_string($name)."%' AND mail LIKE '%".mysql_real_escape_string($mail)."%'";

    }



    $query = "SELECT * FROM usuarios ";

    if(count($conditions) > 0) {
        $query .= "WHERE " . $conditions;
    }

    $result = mysql_query($query);

    while($row = mysql_fetch_array($result)) {
        echo $row['name'] . "<br />";
    }
}
?>

推荐答案

_SERVER ['PHP_SELF']; ?> >
< table >
< tr >
< td > 名称:< / td >
< td > < input type = text name = 名称 < span class =code-keyword> / > < / td >
< / tr >
< tr >
< td > mail:< / td >
< td > < <跨度lass =code-leadattribute>输入 type = text name = mail < span class =code-keyword> / > < / td >
< / tr >
< tr >
< td > & nbsp; < / td >
< td > < 输入 类型 = 提交 name = submit value = 搜索 / > < / td >
< / tr >
< / table >
< / form >






<? php

_SERVER['PHP_SELF']; ?>"> <table> <tr> <td>name:</td> <td><input type="text" name="name" /></td> </tr> <tr> <td>mail:</td> <td><input type="text" name="mail" /></td> </tr> <tr> <td>&nbsp;</td> <td><input type="submit" name="submit" value="Search" /></td> </tr> </table> </form> <?php


con = mysql_connect( localhost ,user,password);

if (!
con = mysql_connect("localhost","user","password"); if (!


con)

{

die('可能 connect: mysql_error());

}



mysql_select_db(database,
con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database",


这篇关于过滤多个字段的搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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