<?php
$result = @mysql_query('SELECT Article FROM news WHERE ID = (SELECT MAX(ID) FROM News)');
if (!$result) {
die('<p>Error performing query: ' . mysql_error() . '</p>');
}
while ($row = mysql_fetch_array($result)) {
echo('<p>' . $row['Article'] . '</p>');
}
?>
Basically, I need to tweak this code, so that it shows the latest three results instead of just the latest one, the newest being the first.
在mysql查询中添加限制
select * from table order by id desc limit 0,3
Have a go with this query:
$result = @mysql_query('SELECT Article FROM news ORDER BY ID DESC LIMIT 3');
FWIW, you may like to sort out the capitalisation of your database columns. The inconsistency will cause you problems in future.
这个查询?
SELECT Article FROM News ORDER BY ID DESC LIMIT 3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.