即时新手,我有一个问题是第二个选择不能调用数据,下面是我的数据库结构和代码的表和列。请给我一只手TQVM!
id,movieid,moviename
id,movieid,venueid,mvenue
<html>
<head>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#movie").change(function(){
var movie=$("#movie").val();
$.ajax({
type:"post",
url:"venue.php",
data:"movie="+movie,
success:function(data){
$("#venue").html(data);
}
});
});
});
</script>
</head>
<body>
Movie :
<select name="movie" id="movie">
<option>-select your movie-</option>
<?php
include "db.php";
$result=mysql_query("SELECT movieid, moviename from movie order by moviename");
while($movie=mysql_fetch_array($result)){
echo "<option value=$movie[moviename]>$movie[moviename]</option>";
} ?>
</select>
Venue :
<select name="venue" id="venue">
<option>-select your venue-</option>
</select>
</body>
</html>
<?php
include "db.php";
$movie=$_POST["movie"];
$result=mysql_query("select movieid,mvenue FROM movievenue where mvenue='$movie' ");
while($venue=mysql_fetch_array($result)){
echo"<option value=$venue[mvenue]>$venue[mvenue]</option>";
}
?>
答案 0 :(得分:0)
<?php
include "db.php";
$movie=$_POST["movie"];
$result=mysql_query("select movieid,mvenue FROM movievenue where mvenue='{$movie['movieid']}' ");
while($venue=mysql_fetch_array($result)){
echo"<option value=$venue[mvenue]>$venue[mvenue]</option>";
}
?>
另外,在您的第一个文件中,您可能希望选择值为电影的ID
echo "<option value=$movie[movieid]>$movie[moviename]</option>";