function update_chats($user_id, $last_updated_id) { global $conn; $last_updated_id = $conn->escape($last_updated_id); $query = "SELECT * FROM chat_history WHERE conv_id > {$last_updated_id} ORDER BY conv_id"; $results = $conn->query($query); $return = array(); if ($results != FALSE) { foreach ($results as $result) { $return[] = populate_div($result['conv_id'], $user_id, $result['username'], $result['text'], $result['is_resource']); } } return implode("", $return); }
<ul class="dropdown-menu" role="menu"> <li><a href="#"><span class="fa fa-map-marker"></span> Invisible</a></li> <li><a href="#"><span class="fa fa-comments-o"></span> Online</a></li> <li><a href="#"><span class="fa fa-lock"></span> Busy</a></li> <li class="divider"></li> <li><a href="logout.php"><span class="fa fa-circle-o-notch"></span> Logout</a></li> </ul> </div> </div> <div id="chat-box-main" class="panel-body chat-box-main"> <?php $chats = get_chats(); if ($chats != FALSE) { $user = $_SESSION['user']; foreach ($chats as $chat) { echo populate_div($chat['conv_id'], $user, $chat['username'], $chat['text'], $chat['is_resource']); } } ?> </div> <div class="chat-box-footer"> <div class="input-group"> <input id="message-body" type="text" class="form-control" placeholder="Enter Text Here..."> <span class="input-group-btn"> <button id="img-send" class="btn btn-info" type="button"><span class="glyphicon glyphicon-camera"</span></button> <input id="img-send-hidden" class="hidden" type="file" name="photo" accept="image/*;capture=camera"/> </span> <span class="input-group-btn"> <button id="send-message" class="btn btn-info" type="button">SEND</button> </span> </div>