How to echo out a specific chat room based on what link the user had clicked previously? PHP
I'm very new to PHP.
I am trying to echo out a chat box/chat room designed specifically for a particular room. Say I have a room called Writer's Block where writer's can gather to 'chat' about their situation. A user will click on an HTML link, something like this:
`<h2 name="WB" id="WB"><a href="www.yyy.com/group.php?id=2/">Writer's Block</a></h2></p>)`
an开发者_如何学JAVAd it will of course take them to the URL that was specified in the link. But my question is: How can I echo out the specific Writer's Block chat room doing this? Should I use MySQL to save different chat rooms such as Writer's Block? How can I show that room based on what the user had clicked on the link previously? Thank you all.
In general you could make a MySQL table, then, for each new chat room give an ID. When a user enters a link with a specified ID, you do something like this:
<?php
// connect to Mysql
// select database
$ChatID = $_GET['id'];
$sql = mysql_query("SELECT * FROM chatrooms WHERE `ChatID` = '$ChatID'");
and then use the next code to echo all the chat messages that have the same ChatID:
while($row = mysql_fetch_array($sql)){
// code
}
精彩评论