1

我有一个搜索查询,其中包括省区市

我需要的是,当用户选择省时,浏览器必须显示与此选择相关的写入结果,当用户选择省和地区时,浏览器必须显示与该省和地区相关的结果,与村庄相同,但

问题是系统显示所有与省区村选择相关的用户结果是同一个eeee

询问:

 $sql = mysql_query("SELECT user_id,first_name, last_name, birth_date, registered_date, 
    s.specialization_name,
    g.governorate_name,
    d.district_name,
    v.village_name 
          FROM members u
                       INNER JOIN  specialization s 
                        ON u.specialization = s.specialization_id
                        INNER JOIN governorate g
                        ON u.governorate = g.governorate_id
                        INNER JOIN districts d
                        ON u.district = d.district_id
                        INNER JOIN village v
                        ON u.village = v.id
                       where (governorate = '' or governorate = '$bygov') or
                             (district = '' or district = '$bydist') or
                             (village = '' or village = '$byvillage')")
                             or die(mysql_error());
4

1 回答 1

1

尝试使用 AND 组成您的 WHERE 选项

$sql = mysql_query("SELECT user_id,first_name, last_name, birth_date, registered_date, 
s.specialization_name,
g.governorate_name,
d.district_name,
v.village_name 
      FROM members u
                   INNER JOIN  specialization s 
                    ON u.specialization = s.specialization_id
                    INNER JOIN governorate g
                    ON u.governorate = g.governorate_id
                    INNER JOIN districts d
                    ON u.district = d.district_id
                    INNER JOIN village v
                    ON u.village = v.id
                   where (governorate = '' or governorate = '$bygov') AND
                         (district = '' or district = '$bydist') AND
                         (village = '' or village = '$byvillage')")
                         or die(mysql_error());
于 2013-05-19T16:22:58.713 回答