Jump to content

Archived

This topic is now archived and is closed to further replies.

Ernster

Showing newest records

Recommended Posts

Hi I need some help, I am a huge newbie to PHP so please dont talk to technical. Basically im building a joomla site anyway I dont how to show the latest 5 records (basically the text submitted in text boxes on a page) I want to show the 5 most ecent entriesthe same page just beneath the text boxes. How do I do this and which variables/tags do I need to use? Thanks.

Share this post


Link to post
Share on other sites
I'm assuming these entries are from a db? probably an sql db? what kind of page is this, are these items listed elsewhere? is this stuff already logged by the site? Be a bit more specific about it.

In any case if they're from the db you need to know the fields, and the id field which I assume it has

$sql = "SELECT * FROM `table` ORDER BY `id` DESC LIMIT 5";
$result = mysql_query ($sql) or die (mysql_error ());
while ($data = mysql_fetch_array ($result))
{
?><tr><td><?=$data['text']?></td> etc.... <?
}

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.