ストリーム
1)CSE
2)ECE
学期
1)1
2)3
3)5
件名
1)DBMS
2)OS
4)SS
3)DCLD私は学期ドロップダウンボックス、DBMSからCSEからストリームドロップダウンボックスとを選択する時期
上記の3つのフィールドは、私が欲しいdatabase.Whatであるがある件名から選択する必要がありますドロップダウンボックスなど。
Iはすでにすなわちストリームと件名 iはストリームからオプションを選択すると、対応する値が学期ドロップダウンから
以下のコードの実行を選択した手段2つのドロップダウンボックスのオプションの選択を設定していますストリームと学期ドロップダウンから選択件名ドロップダウンで私を助けてwell.Please
コードは以下である:
select.php
<html>
<head>
<link rel="stylesheet" type="text/css" href="select_style.css">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
function fetch_select(val)
{
$.ajax({
type: 'post',
url: 'fetch_data.php',
data: {
get_option:val
},
success: function (response) {
document.getElementById("new_select").innerHTML=response;
}
});
}
</script>
</head>
<body>
<p id="heading">Select Subject for Timesheet</p>
<center>
<div id="select_box">
<select onChange="fetch_select(this.value);">
<option>Select Stream</option>
<?php
$host = 'localhost';
$user = 'xx';
$pass = 'zzz';
mysql_connect($host, $user, $pass);
mysql_select_db('sample');
$select=mysql_query("select stream from streamSub group by stream");
while($row=mysql_fetch_array($select))
{
echo "<option>".$row['stream']."</option>";
}
?>
</select>
<select id="new_select">
</select>
</div>
</center>
</body>
</html>
fetch_data.php
<?php
if(isset($_POST['get_option']))
{
$host = 'localhost';
$user = 'XX';
$pass = 'ZZZ';
mysql_connect($host, $user, $pass);
mysql_select_db('sample');
$stream = $_POST['get_option'];
$find=mysql_query("select subject from streamSub where stream='$stream'");
while($row=mysql_fetch_array($find))
{
echo "<option>".$row['subject']."</option>";
}
exit;
}
?>
共有データベーステーブルもあります。 –
@ SujalPatelデータベースのスクリーンショットは共有されています。 –