AbydosGater Posted October 30, 2006 Share Posted October 30, 2006 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?ThanksAbydos Quote Link to comment Share on other sites More sharing options...
trq Posted October 30, 2006 Share Posted October 30, 2006 [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. Quote Link to comment Share on other sites More sharing options...
AbydosGater Posted October 30, 2006 Author Share Posted October 30, 2006 Great Thanks for the fast reply! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.