我有这个代码,但在我运行之后,我看到一张空白图片;为什么? 我正在尝试创建一个显示用户信息的myaccount页面。
if (isset($_SESSION['uid'])){
$uid= get_current_user();
$sql = "SELECT uid, first,last,sem,email FROM user WHERE uid='$uid'";
$cursor = mysqli_query($conn,$sql); // for example
$result = mysqli_fetch_row($cursor);
$n = mysqli_num_fields($cursor);
while ($result) {
for ($i=0; $i < $n; $i++) {
$val= $result[$i];
echo "$val,";
}
echo '<br>';
$result = mysqli_fetch_row($cursor);
}
$conn->close();
}
答案 0 :(得分:0)
if (isset($_SESSION['uid'])) {
$uid = $_SESSION['uid'];
$sql = "SELECT uid, first,last,sem,email FROM user WHERE uid='$uid'";
$cursor = mysqli_query($conn, $sql); // for example
$result = mysqli_fetch_row($cursor);
while ($result = mysqli_fetch_row($cursor)) {
print_r($result);
echo '<br>';
}
$conn->close();
}
答案 1 :(得分:0)
也许您的$ _SESSION [&#39; uid&#39;]未设置?尝试回声。