I am trying to create online chat between admin and user by using PHP and MySQL.for that I created a common table for saving messages from admin and users. and I used two while loops with different conditions like printing their messages.by using while loops together, one loop only working..can you please help me to work 2 while loops work simultaneously...
here is my PHP code:-
<?php
$userid=$_SESSION['registerid'];
$sql1="select * from registers where registerid='$userid'";
$query1=mysql_query($sql1,$con);
$result1=mysql_fetch_array($query1);
$username=$result1['name'];
$sql18="select * from usertoadmin_chat where userid='$userid' and sender='$username'";
$query18=mysql_query($sql18,$con);
$sql19="select * from usertoadmin_chat where sender='Admin' and userid='$userid'";
$query19=mysql_query($sql19,$con);
 ?>
here my displaying code:-
 <form method="post" action="#">
                    <div class="chat-content chat-scrollbar">
                      <?php while($row19=mysql_fetch_array($query19)) { ?>
                      <?php while($row18=mysql_fetch_array($query18)) { ?>
                        <div class="author-chat">
                            <h3><?php echo $row18['sender'];?><span class="chat-date"><?php echo $row18['time'];?></span></h3>
                            <p><?php echo $row18['msg'];?></p>
                        </div>
                        <div class="client-chat">
                            <h3><?php echo $row19['sender'];?><span class="chat-date"><?php echo $row19['time'];?></span></h3>
                            <p><?php echo $row19['msg'];?></p>
                        </div>
<?php } ?>
<?php } ?>
                    </div>
                    <div class="chat-send">
                        <input type="text" name="msg" placeholder="send msg..." />
                        <span><button type="submit" name="submit">Send</button></span>
                    </div>
                  </form>
 
     
    