Jump to content


Photo

Showing newest records


  • Please log in to reply
1 reply to this topic

#1 Ernster

Ernster
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 15 June 2006 - 03:07 AM

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.

#2 joquius

joquius
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 15 June 2006 - 07:43 AM

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.... <?
}
z..z..z..z..z..z..z..z..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users