我正在使用php函数与mysql数据库连接挣扎。我似乎无法调用数据库连接并返回任何数据。有什么想法吗?
<?php
$useID=$_POST['use_id'];
function dbConnect(){
$conn= mysqli_connect("localhost", "name", "pword", "path");
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
return $conn;
}
function dropDown(){
$conn=dbConnect();
$query="SELECT * FROM usesList";
$myData = mysqli_query($conn, $query);
$row=mysqli_fetch_array($myData);
$options="";
while ($row=mysqli_fetch_array($myData)) {
$options.="<option value='" . $row['use_id'] ."' >" . $row['use_name'] ."
</option>";
}
}
dropDown();?>