我的代码工作正常,但我有问题,我只能通过第一个选择选项搜索而第二个选择选项不起作用,第一个选择选项($_REQUEST["area"]<>'')" and "
($_REQUEST["area"]<>'')
工作正常,但我只能获取通过
第一个选择我写的选项,否则给我错误和更改时
那些我有同样的问题,所以我想使用两个选择选项
过滤我的搜索。
<?php
if ($_REQUEST["string"]<>'') {
$search_string = " AND (name LIKE '%".mysql_real_escape_string($_REQUEST["string"])."%' OR
specialization LIKE '%".mysql_real_escape_string($_REQUEST["string"])."%' OR
address LIKE '%".mysql_real_escape_string($_REQUEST["string"])."%' OR
telephone LIKE '%".mysql_real_escape_string($_REQUEST["string"])."%' OR
time LIKE '%".mysql_real_escape_string($_REQUEST["string"])."%'
)";
}
if ($_REQUEST["area"]<>'') {
$search_area = " AND location_id='".mysql_real_escape_string($_REQUEST["area"])."'";
}
if ($_REQUEST["category"]<>'') {
$search_category = " AND cate_id='".mysql_real_escape_string($_REQUEST["category"])."'";
}
else {
$sql = "SELECT * FROM informations WHERE id>0".$search_string.$search_area.$search_category;
}
$sql_result = mysql_query ($sql) or die ('request "Could not execute SQL query" '.$sql);
if (mysql_num_rows($sql_result)>0) {
while ($row = mysql_fetch_assoc($sql_result)) {
?>
<tr>
<td><?php $sel_cate2 = "SELECT title FROM categories where id = ".$row['cate_id']." ";
$done_cate2 = mysql_query($sel_cate2);
$get2 = mysql_fetch_array($done_cate2);
echo $get2["title"]; ?></td>
<td><?php $sel_cate2 = "SELECT location FROM locations where id = ".$row['location_id']." ";
$done_cate2 = mysql_query($sel_cate2);
$get2 = mysql_fetch_array($done_cate2);
echo $get2["location"]; ?></td>
<td><?php echo $row["name"]; ?></td>
<td><?php echo $row["specialization"]; ?></td>
<td><?php echo $row["address"]; ?></td>
<td><?php echo $row["telephone"]; ?></td>
<td><?php echo $row["time"]; ?></td>
</tr>
<?php
}
} else {
?>
<tr><td colspan="5">No results found.</td>
<?php
}
?>
</table>