我正在尝试从“设备名称”特定列中获取数据,并将其显示在我创建的保管箱中。这似乎根本不起作用。请你帮助我好吗。我是php新手,还在学习。多谢您的协助。谢谢!
<php?
$hostName = "localhost";
$dbusername="root";
$dbpassword='';
$dbhandle = mysql_connect($hostName, $dbusername, '' ) or die("Could not connect");
$selected = mysql_select_db("test", $dbhandle);
$query = "SELECT * FROM `devicehotsheet`";
$result1 = mysql_query($selected, $query);
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body onload="hideTotal()">
<form method="POST" id="device" class="device">
<center class="all">
<div class="data">
<label class="req">Select The Device</label>
<select class="selectDevice" id="selectDevice" onChange="calculateTotal()">
<?php while($row1 = mysql_fetch_array($result1)):;?>
<option><?php echo $row1[1];?></option>
<?php endwhile;?>
</select>
答案 0 :(得分:0)
对我有用。试试这个:
<?php
$hostName = "localhost";
$dbusername="root";
$dbpassword='';
$dbhandle = mysql_connect($hostName, $dbusername, '' ) or die("Could not connect");
$selected = mysql_select_db("test", $dbhandle);
$query = "SELECT * FROM `devicehotsheet`";
//Changed line of code below:
$result1 = mysql_query($query, $dbhandle);
?>
<!DOCTYPE html>
<html>
<head></head>
<body onload="hideTotal()">
<form method="POST" id="device" class="device">
<center class="all">
<div class="data">
<label class="req">Select The Device</label>
<select class="selectDevice" id="selectDevice" onChange="calculateTotal()">
<?php while($row1 = mysql_fetch_array($result1)):;?>
<option><?php echo $row1[1];?></option>
<?php endwhile;?>
</select>
</div>
</center>
</form>
</body>
</html>