Jump to content


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


Chat Script limit mysql display?

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..

$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\">";

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?


Share this post

Link to post
Share on other sites
$query = "SELECT * FROM chat_rc1 ORDER BY id DESC LIMIT 25";

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.

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.