Returning One Result
Posted: Tue Feb 14, 2006 3:43 pm
My question is:
The code below works great for returning a list of current articles but I would like the homepage to just display the newest article. How do I make the code return only the single most current item in my database?
Thank you,
Peter
The code below works great for returning a list of current articles but I would like the homepage to just display the newest article. How do I make the code return only the single most current item in my database?
Code: Select all
if(!isset($_GET['id']))
{
$self = $_SERVER['PHP_SELF'];
$query = "SELECT id, title, abstract FROM article ORDER BY id DESC";
$result = mysql_query($query) or die('Error : ' . mysql_error());
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
list($id, $title, $abstract) = $row;
$content .= "
<b><a href=\"$self?id=$id\">$title</a></b><br />
$abstract<br /><br />
<a href=\"$self?id=$id\">Read Full Article...</a><br /><hr>\r\n";
}Peter