链接列表框未过滤 [英] Chained List Boxes Not Filtering
本文介绍了链接列表框未过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一系列三个列表框,但是第一个框正确加载;第二个和第三个是加载但不是基于先前选择的过滤。这些表是这样的;
tblRestaurants
RestID
RestName
tblLocations
LocationID
RestID
CityID
AreaID
tblCities
CityID
CityName
tblAreas
AreaID
AreaName
我也在使用一个功能:
I have a series of three List Boxes, The first box is loading properly, however; the second and the third are loading but not filtering based on the previous selection. The tables are as such;
tblRestaurants
RestID
RestName
tblLocations
LocationID
RestID
CityID
AreaID
tblCities
CityID
CityName
tblAreas
AreaID
AreaName
I am using a function as well:
function createoptions($table , $id , $field , $condition_field , $value)
{
$sql = sprintf("select * from $table WHERE $condition_field=%d ORDER BY $field" , $value);
$res = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($res) > 0) {
while ($a = mysql_fetch_assoc($res))
$out[] = "{optionValue: {$a[$id]}, optionDisplay: '$a[$field]'}";
return "[" . implode("," , $out) . "]";
} else
return "[{optionValue: -1 , optionDisplay: 'No result'}]";
}
if (isset($_GET['tblRestaurants'])) {
echo createoptions("tblLocations" , "CityID" , "Street" , "RestID" , $_GET['tblRestaurants']);
}
if (isset($_GET['AreaBox'])) {
echo createoptions("tblAreas" , "AreaID" , "AreaName" , "AreaID = tblLocations.AreaID" , $_GET['tblLocations']);
}
die();
这是建立三个列表框:
And this is to build the three Listboxes:
<form method = " post=">
<br mode=" hold=" />
<select name = " restname=" id=" restid=">
<br mode=" -1=">--Select--</option>
<br mode=" tblrestaurants=", " cityid="><br mode=" tbllocations=", " areaid="><br mode=">
推荐答案
表,
table ,
id ,
id ,
>
field ,
field ,
这篇关于链接列表框未过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文