Jump to content

Chat Script limit mysql display?


AbydosGater

Recommended Posts

Hi i have a basic chat script up and running, i got it done within an hour or so last night so its very basic at the moment.

But the section of my code that displays chat is..

[code]
$query = "SELECT * FROM chat_rc1 ORDER BY id DESC";
$result = mysql_query($query);
while($post = mysql_fetch_array($result)) {
$handle = $post['handle'];
$ip = $post['ip'];
$timestamp = $post['timestamp'];
$message = $post['message'];

echo "<i><b>$handle</b> @ $timestamp from $ip says:</i> <br> $message<br><br>";

}
echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"10; URL=recieve.php\">";

[/code]
So it displays the posts, and then every 10 seconds the page refreshs.

As you can see there it displays the posts from the newest to oldest in the DESC.
But what i was wondering how would i use LIMIT to limit it to only display the last say 25 posts?
how could i do this?

Thanks
Abydos
Link to comment
Share on other sites

[code=php:0]
$query = "SELECT * FROM chat_rc1 ORDER BY id DESC LIMIT 25";
[/code]

Ive got to ask though... is there any reason your using a database? Are you going to be keeping these chats? I meen, thats allot of work on the server for no reason otherwise.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.