我正在尝试回复userID
中存储的最后MySQL
。但它没有显示。没有显示错误。
我试过了:
$stmti = $reg_user->runQuery("SELECT * FROM tbl_users");
$rowi = $stmti->fetch(PDO::FETCH_ASSOC);
$tf = $rowi['userID'];
echo $tf;
答案 0 :(得分:1)
/ *注意:这仅适用于mysqli 更改参数" host"," username"," password"," db_name"跟你的 自己的 * /
$link = mysqli_connect("host","username","password","db_name");
$query = " SELECT *
FROM tbl_users";
$rows = array();
$result = mysqli_query($link, $query);
while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
$rows[] = $row;
$lastID = 0;
for ($i = 0 ; $i < count($rows) ; $i++)
$lastID = $i;
echo $rows[$lastID]["userID"];
答案 1 :(得分:0)
试试这个:
$sth = $reg_user->prepare("SELECT MAX(userID) as userID FROM tbl_users");
$sth->execute();
$result = $sth->fetch(PDO::FETCH_ASSOC);
$tf= ($result['userID']);
echo $tf;