请关注此帖子 请查看我的以下帖子链接多个选择 https://stackoverflow.com/questions/11712199/chained-multiple-selects
我有这样的代码,用户选择特定的医生类别,然后选择他想要查看的地区。状态后他需要点击车站(在选定的地区)
医生 >> 区 >> 站
Here is the code
<html>
<body>
<form action="process.php" method="post">
<select name="cat">
<?php
$sql="select distinct Category from doctors order by Category asc";
$query=mysql_query($sql);
while($row=mysql_fetch_array($query))
{
echo "<option value='{$row[Category]}'>{$row[Category]}</option>";
}
?>
</select>
<select name="station">
<?php
$sql_1="select distinct Station from doctors order by Station asc";
$query_1=mysql_query($sql_1);
while($row=mysql_fetch_array($query_1))
{
echo "<option value=".$row[Station].">".$row[Station]."</option>";
}
?>
</select>
<input name="C" type="submit" />
</form>
</body>
</html>
进程.php
$mySqlStm ="SELECT Name FROM doctors WHERE Category='$myValue' and Station='$myStation'";
$result2 = mysql_query($mySqlStm) or die("Error:mysql_error()");
if(mysql_num_rows($result2) == 0){
echo("<br/>no records found");
}
ELSE
{
echo "<table border='1'>";
//ECHO THE RECORDS FETCHED
while($row = mysql_fetch_array($result2))
{
echo "<tr>";
//echo "<td>" . $row['Station'] . "</td>";
echo "<td>" . $row['Name'] . "</td>" ;
//echo "<td>" . $row['Phone 1'] . "</td>";
//echo "<td>" . $row['Mobile'] . "</td>";
}
我希望在选择地区时自动填充车站类别,并且在选择医生类别时必须自动填充地区。
我该怎么做?我更喜欢 Javascript,因为我对它了解一点。
另外,我将所有数据都存储在一个数据库中,如下所示
类别 |车站|区 |名称 |资质等
Ajax + jQuery 将通过几行代码为您完成此操作。
教程在这里:Ajax+jQuery 教程 http://www.w3schools.com/jquery/jquery_ajax.asp
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)