我想从 mysql 表中填充下拉值。我在 html 页面中使用了加载事件,但我不知道这段代码不起作用。
网页
<!DOCTYPE html>
<html>
<head>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#select1").load("se2.php");
});
});
</script>
</head>
<body>
<select id="select1"></select>
<button>Get External Content</button>
</body>
</html>
se2.php
<?php
$dbhandle = mysql_connect("localhost","root","")
or die("Unable to connect to MySQL");
$selected = mysql_select_db("student",$dbhandle)
or die("Could not select examples");
$result1 = mysql_query("SELECT column1 FROM information");
while($row=mysql_fetch_array($result1))
{
if($row['column1']!=NULL)
{
echo "<option value='$row[column1]'>$row[column1]</option>";
}
}
?>