PDA

View Full Version : Resolved php echo data



john0611
03-13-2009, 01:52 PM
Hi, I am wondering if anyone could help me here:confused: I have trying to sort this 1 out for a while now:)

Here I have the php code which gets data from mysql, and echo’s it on the browser, problem is it echo’s all the fields of data, and I just like it to echo the first fields only.

so, it echo’s the newest field record only first by title, or id, then date, then listing just once.


<?php

// query db
$sql = mysql_query ("SELECT listingid, Title, Date, Listing, DATE_FORMAT(Date, '%d-%m-%Y') as Date FROM `track-listing` ORDER BY Date DESC");
// echo result from db
while ($row = mysql_fetch_assoc($sql)){
echo "{$row['listingid']}" .
($row['Title']) . "<font size=1 color=#878787>" . "* :: *" . ($row['Date']) . ($row['Listing']) . "</font>" . "<br>";

}
?>

Any help and suggestion is greatly appreciated

Schmoopy
03-13-2009, 02:45 PM
add "LIMIT 1" to your query:



$sql = mysql_query ("SELECT listingid, Title, Date, Listing, DATE_FORMAT(Date, '%d-%m-%Y') as Date FROM `track-listing` ORDER BY Date DESC LIMIT 1");

john0611
03-13-2009, 09:46 PM
FANTASTIC! Just what i needed!

Thank you for your help!:D