tags:

views:

29

answers:

1

This is my php code...........

$root = "http://localhost/";
$sql = mysql_query("SELECT * FROM mychat WHERE (too='$mid' AND froom='$uid') OR (too='$uid' AND froom='$mid') ORDER BY id ASC");
    while($ro=mysql_fetch_array($sql)){
        $from = $ro['froom'];
        $to = $ro['too'];
        $text = $ro['text'];
        $time = $ro['time'];
        $last_count = $ro['last_count'];
        echo '<li class="chat_li">
        <font face="MS Sans Serif" size="1">'.$froom.'</font></a> says: &nbsp; '.wordwrap($text, 1000,"<br>\n", true).'
         <br><font size="1" color="#777777">'.$time.'</font>
        </li>';
}   

but it is showing only user1 name and all text but not showing the appropriate user with text msg............

how can i fix that

my database table.........

id, froom, too, text, time

and here is my output.......... if user1 types........[ ssss] and user2 types.....[ 1244]

output is always.

user1says: ssss 1min ago

user1says: 1244 50sec ago

+1  A: 

Try this

$root = "http://localhost/";
    $sql = mysql_query("SELECT * FROM mychat WHERE (too='$mid' AND froom='$uid') OR (too='$uid' AND froom='$mid') ORDER BY id ASC");

    $ro= mysql_fetch_array($sql);
    for($i=0;$i< count($ro);$i++)
    {        
            $to[$i] = $ro[$i]['too'];
            $last_count[$i] = $ro[$i]['last_count'];
            echo '<li class="chat_li">

            <font face="MS Sans Serif" size="1">'.$ro[$i]['froom'].'</font></a> says:.wordwrap($ro[$i]['text'], 1000,"<br>\n", true).'
                    <br><font size="1" color="#777777">'.$ro[$i]['time'].'</font>
            </li>

}   
streetparade
it's out put is like.......1says: 12says:23says:34says:4
Web Worm