jeudi 16 juin 2016

Variable don't work in else

I have this code for chat and there's problem with variable $profile_pic. It contains path to profile pic and when i put it in echo before if, it work, of i put it in if it works, but if i put it in else it doesn't work.

$result_msg = $link->query("SELECT  * FROM chat ORDER BY msg_id");
while($row_msg = $result_msg->fetch_assoc()) {
    $sender = $row_msg['sender'];
    $qry = mysqli_query($link, "SELECT * FROM users WHERE nick = '".$sender."'");
    $data = mysqli_fetch_array($qry, MYSQLI_BOTH);
    $profile_pic = $data["profile_pic"];
    $message = $row_msg["message"];
    if($sender == $_SESSION['admin_auth'] or $_SESSION['user_auth']){echo '<div class="messageme"><div class="messagemebody">' . $row_msg["message"]. '</div><br></div>';}
    else {
    echo '<div class="messageyou"><img src="'.$profile_pic.'" alt="profile_pic" class="profile_pic_chat"><div class="messageyoubody">'.$message.'</div><br></div>';
}
} ?>

Aucun commentaire:

Enregistrer un commentaire