Hi friends i am learning php and creating a chat site script
i am able to show messages from mysql db in chat room but i dont know how to show private messages
by using this code is smarty
template code
i am able to show messages in room name general by id 1
it shows all messages in that room
i want to show private msgs to user to whom it is being sended privately
i means if user 1 send private msg to user 2 it shows message to only both of them not to user 3
while if message is send to all users it shows to all i hope u understand what i said
i am able to show messages from mysql db in chat room but i dont know how to show private messages
by using this code is smarty
PHP Code:
function chat_messages($rid)
{
$msgs = array();
$query = mysql_query("SELECT * FROM chat_messages WHERE room_id = $rid");
while ($msg_list = mysql_fetch_assoc($query)){
$msgs[] = $msg_list;
}
return $msgs;
}
PHP Code:
{foreach from=$msgs item=msg}
<div class="{cycle name="class" values="main,main2"}"><a href="../profile.php?id={$msg.user_id}">{$msg.user_name}</a> : {$msg.message}</a></div>
{/foreach}
it shows all messages in that room
i want to show private msgs to user to whom it is being sended privately
i means if user 1 send private msg to user 2 it shows message to only both of them not to user 3
while if message is send to all users it shows to all i hope u understand what i said
Comment