使用 php 从 mysql table 获取最后一行
Get last line from a mysql table with php
试图从 mysql table 和 php
中获取最后一行
$lastline="select COALESCE(ID, 0) from $sectionN order by ID desc limit 1";
$lastline=mysql_query($lastrow);
echo $lastline;
但它返回 "Resource id #9"
您需要实际获取结果,然后访问适当的数组索引。
$lastrow=mysql_fetch_array(mysql_query($lastrow))[0];
+开始使用mysqli
$lastrow=mysqli_fetch(mysqli_query($lastrow))[0];
试图从 mysql table 和 php
中获取最后一行$lastline="select COALESCE(ID, 0) from $sectionN order by ID desc limit 1";
$lastline=mysql_query($lastrow);
echo $lastline;
但它返回 "Resource id #9"
您需要实际获取结果,然后访问适当的数组索引。
$lastrow=mysql_fetch_array(mysql_query($lastrow))[0];
+开始使用mysqli
$lastrow=mysqli_fetch(mysqli_query($lastrow))[0];