尝试获取表格中的最后一行,但抛出错误......
'警告:mysqli_fetch_assoc()期望参数1为 mysqli_result,'
中给出的字符串
$recents = "SELECT * FROM list ORDER BY id DESC LIMIT 1";
Ah yes, forgot to execute query here
if ($result = mysqli_fetch_assoc($recents)) {
$mName = $result['name'];
$mDesc = $result['description'];
$mCost = $result['cost'];
}
答案 0 :(得分:2)
您需要传递查询结果,而不是查询字符串。
$sql = "SELECT * FROM list ORDER BY id DESC LIMIT 1";
$recent = mysqli_query($connetion, $sql);
答案 1 :(得分:1)
您忘记使用该语句来运行查询
$results=mysqli_query($conn,$recents)