php ajax sohbet sorun

1 Cevap php

Bu benim php kodu ...........

$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>';
}   

ama sadece user1 adı ve tüm metni gösteren ancak metin msj ile uygun kullanıcı gösterilmiyor ............

ben bu nasıl düzeltebilirim

benim veritabanı tablosu .........

id, froom, too, text, time

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

çıkışı her zaman.

user1says: ssss 1min ago

user1says: 1244 50sec ago

1 Cevap

Bu deneyin

$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>

}