tags:

views:

50

answers:

1

Hello, 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>)`

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

A: 

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

}
Crembo
Crembo, thanks a lot for your advice. However, I'm a bit confused about exactly what code would go inside while($row = mysql_fetch_array($sql)){ }As of now, I have a chatbox.php file that contains the code for a normal chatroom. So would I simply put the code from the chatbox.php file inside the brackets? But, if I do this, how will be the chatroom unique to the topic? As in, how will I echo the name 'writer's block' for the specific room and a different name for a different room. Feel free to ask me to explain in detail if I'm not explaining myself well. Thank you for your patience.
Newbie_25