小弟目前写了一个php档要从数据库捞数据出来,现在要做进一步的显示,结果在
里面设了一个button就失效了,js的function都跑不出来,想请问是什么问题
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf8">
<style>
.body{
font-family:MS Gothic;
}
</style>
<script type="text/javascript">
function change(){
var png=document.getElementById('unbook');
if(png.src.match("book1")){
png.src="img/test/book2.png";
}
else{
png.src="img/test/book1.png";
}
}
function pass(gg){
document.write(gg);
}
</script>
</head>
<body>
<?php
$q = $_GET['a'];
$con = mysqli_connect('localhost','root','','demo1');
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}
mysqli_select_db($con , "demo1");
mysql_query("SET NAMES 'UTF8'");
$sql="SELECT * FROM od where origin='$q'";
$result = mysqli_query($con,$sql);
while($row = @mysqli_fetch_array($result)) {
?>
<img src="img/test/book2.png" id="unbook" onclick="change()" style="float:left; ">
<button style="display:block;
margin:30px;
border-width:1px; border-style:solid; border-color:grey;
background-color:rgb(248,248,245);
width:80%;
height:100px;" onclick="pass(this.value)" value="vfdcz">
<img src="img/1.jpg" style="display:inline; float:left; height:90px;">
<?php
echo "<div >";
echo "出发: " . $row['origin'] . "";
echo "</div>";
echo "<div>";
echo "停靠: " . $row['stop'] . "";
echo "</div>";
echo "<div>";
echo "终点: " . $row['destination'] . "";
echo "</div>";
?>
</button>
<?php
}
mysqli_close($con);
?>
</body>
</html>