Page 1 of 1

Show only last 10 items

Posted: Sun Jul 04, 2004 8:13 pm
by Revan
Hello, i was wondering, IF i made a Forum script, how would i make it so it only shows the last ...10 threads? ive always wondered this, i know you use a WHILE

Posted: Sun Jul 04, 2004 8:17 pm
by John Cartwright
you could do in your query

Code: Select all

<?php

$result = @mysql_query("SELECT * posts_table ORDER BY `date` DESC LIMIT 10");

?>

Posted: Sun Jul 04, 2004 8:26 pm
by Revan
Thank you, ill try it on my new script.

Posted: Sun Jul 04, 2004 10:00 pm
by d3ad1ysp0rk
Phenom wrote:you could do in your query

Code: Select all

<?php

$result = @mysql_query("SELECT * posts_table ORDER BY `date` DESC LIMIT 10");

?>
Why do you always use @function?

Bad habit.

Posted: Mon Jul 05, 2004 12:06 am
by John Cartwright
I'm sorry :*(

let me jus add this tho

Code: Select all

<?php

$result = mysql_query("SELECT * posts_table ORDER BY `date` DESC LIMIT 10") or die("Query Error: ".mysql_error()) ;

?>

Posted: Mon Jul 05, 2004 5:36 am
by mikusan
Just for fun,

Will PHP be very confused and have existential problems if you do the following?

Code: Select all

$result = @mysql_query("SELECT * posts_table ORDER BY `date` DESC LIMIT 10") or die("Query Error: ".mysql_error()) ;
I mean we are suppressing all errors, yet we ask it to die.

Hehe, okay okay, i am sorry, that was lame...

Posted: Mon Jul 05, 2004 9:34 am
by evilmonkey
You're not asking for a PHP error, but a MySQL error...should work (Just my thoughts, haven't actually tried it out).

Posted: Mon Jul 05, 2004 12:49 pm
by d3ad1ysp0rk
Yes, it will work.

Posted: Tue Jul 06, 2004 7:29 pm
by Revan
I tryed it, but it still showed more then 10

:/

edit: nvm i fixed it