嘿,我正在使用以下代码从DB检索内容。但是,它可以正常工作,变量名的值始终为空。
<?php
require_once('dbconnect2.php');
session_start();
if (isset($_SESSION['u_id'])) {
$sql = "SELECT race_Name FROM tbl_Races";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt,$sql)) {
header("../index.php?error=sqlerror");
exit();
}else{
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
mysqli_stmt_bind_result($name);
$resultcheck = mysqli_stmt_num_rows($stmt);
if ($resultcheck > 0) {
while (mysqli_stmt_fetch($stmt)) {
echo "<option>".$name."</option>";
}
}
}
}
?>
有什么建议吗?