Re: Selct & show certain num records ?
| From: | Alan McFarlane | Date: | Thu, 31 Jan 2002 18:20:33 +0000 |
| Subject: | Re: Selct & show certain num records ? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-16358@lists.php.net to get a copy of this message | ||
$table_name = "my_table";
$timestamp_field = "date_posted"; /* or something similar */
$max_records = 5;
$sql = sprintf("SELECT * FROM %s ORDER BY %s DESC LIMIT %d", $table_name,
$timestamp_field, $max_records):
$result = mysql_query($sql);
/* ... */
Dave Carrera <dave@davecarrera.com> wrote in message
news:000601c1aa2c$84eb4a60$f94a27d9@authorised...
> Hi All
>
> I know this has been covered here before but can someone please remind
> me how to selct just the 5 latest records in my db and show them in list
> form.
>
> Just like phpbuilder.com dose
>
> I thank you in advance for repeating this information.
>
> Dave C :-)
>
>