请关注这篇文章,而不是查看我下面的文章,请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>Process.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,因为我对它有一点了解。另外,我把所有的数据都放在一个数据库里,看起来像这样
类别|车站|地区|名称|资格等
发布于 2012-07-24 14:37:41
Ajax + jQuery只需几行代码就可以做到这一点。
这里是教程:Ajax+jQuery Tutorial
发布于 2012-07-24 14:41:36
发布于 2012-07-24 14:54:32
https://stackoverflow.com/questions/11625365
复制相似问题