尝试从数据库获取数据并显示到保管箱

时间:2018-08-08 05:37:02

标签: php html

我正在尝试从“设备名称”特定列中获取数据,并将其显示在我创建的保管箱中。这似乎根本不起作用。请你帮助我好吗。我是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>

1 个答案:

答案 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>