Hi,
unfortunately there is not.... so these are just code snippets
database structure:
Note: this assumes magic_quotes on, otherwise add addslashes()Code:create table chat ( id int not null auto_increment primary key, user varchar(20), posted int, -- actually a timestamp message text );
Now, on the flash side, an interval timer would repeatedly send the id to the server and get the id back. If there is a chat variable in the response, add to display (and possibly scroll to the end so it becomes visible)Code:<? include "db.php" if(isset($_POST['user']) && isset($_POST['message'])) { $user = $_POST['user']; $message = $_POST['message']; mysql_query("insert into chat (user, posted, message) values ('$user', unix_timestamp(), '$message')"); } else if(isset($_POST['id'])) { $lastid = $_POST['id']; if(!ereg('^[1-9][0-9]*', $lastid)) exit; $ret = mysql_query("select * from chat where id > $lastid order by id"); $chat = ''; while($row = mysql_fetch_array($row)) { $chat .= "posted by <font color='#00ff00'>{$row['user']}</font> on " . date("h:m", $row['posted']) . "<br>" . htmlspecialchars($row['message']) . "<br>---------<br>"; $lastid = $row['id']; } if($chat != '') print "&chat=$chat"; print "&id=$lastid&"; }
MusicmanCode:var lastid = 0; function poll() { var sendlv = new LoadVars(); var retlv = new LoadVars(); sendlv.id = lastid; retlv.onLoad = function() { lastid = this.id; if(this.chat != undefined) { chattext.htmlText += this.chat; chattext.scroll = chattext.maxscroll; } }; }




Reply With Quote