2012-07-24 114 views
0

請按照這篇文章,而不是檢查我下面的帖子,請 Chained multiple selectsPHP從數據庫中填充數據時區選擇

我有這樣的代碼在用戶選擇的醫生的具體類別,然後在區中,他想去看看它。狀態後,他需要點擊站(在選定的地區) 醫生>> >>區站

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,因爲我對它有一點了解。 此外,我有一個數據庫中的所有數據它看起來像這樣

類別|站| |區|名稱|資格等

+1

您可以根據您的要求使用ajax – Jalpesh 2012-07-24 06:37:19

回答

0

演示的國家,州和市here

代碼是Here

自定義你的方式..

可以在findCity.php更改代碼以Process.php和JS/location.js 您有:

$.ajax({ 
    type: "GET", 
    url: "findCity.php", 
    data: strURL, 
    cache: false, 
    success: function(d){ 
    $('#citydiv').show().html(d); 
    } 
}); 

#citydiv是其中一部分將更改爲您在Process.php中獲得的結果