我试图只显示我的表StudentInfo的最后两行中的timein和timeout列。 下面是代码:
$query = mysql_query("
SELECT timein, timeout
FROM studentInfo
WHERE name = 'Student'
ORDER BY time DESC
LIMIT 2
")
or die("Error querying database ".mysql_error());
while($minutes = mysql_fetch_array($query)){
echo "timein: ".$minutes['timein']."<br />";
echo "timeout: ".$minutes['timeout']."<br />";
答案 0 :(得分:1)
试试这个,
$query = mysql_query("SELECT timein, timeout FROM studentInfo WHERE name = 'Student' ORDER BY id DESC LIMIT 2") or die(mysql_error());
while($minutes = mysql_fetch_assoc($query)){
echo "timein: ".$minutes['timein']."<br />";
echo "timeout: ".$minutes['timeout']."<br />";
}
-
尝试使用mysql mysqli,因为这个已弃用