我正在尝试从两个列访问,一个来自Count(userid),另一个来自rank。此代码确实返回计数但不返回 秩。
<?php
$myusername = strtolower($_POST['username']);
$mypassword = md5($_POST['password']);
$sql = "SELECT COUNT(userid), rank FROM users_ WHERE "
. "username = ? AND password = ?"; // note the "?" placeholders
$stmt = $dbh->prepare($sql);
$stmt->execute([$myusername, $mypassword]);
$row = $stmt->fetch();
//echo $row[0]; // this displays the returned count.
echo $row[1];
if ($row[0] == 1) {
header("location: dashboard.php");
} else {
$error = "Invalid username or password.";
}