ganesanji Posted December 2, 2008 Share Posted December 2, 2008 Hi All, I am developing a simple Instant Messenger in PHP/MySQL with Ajax. I created one page for displaying online friends list. In that page I need to check the DB for waiting message, if there means it will open a popup chat window. My problem is after sending a message to a person, i need to refresh the friends.php for checking the waiting messages in DB, then it will open the popup chat window in the opposite user side(means with whom i am chatting). If I put meta tag refresh for friends.php page, it every time refresh the friends.php and the popup chat window. It is not good for ajax chat. I need to refresh the friends.php for every 5 seconds to check the DB for waiting message, if exist means , i need to open popup chat window. Anything solution available for this? plz help me....adavanced thanks.... here i have given the contents of friends.php page <meta http-equiv="refresh" content="5"> <?php $sql1 = "SELECT * FROM `messages` WHERE touserID='".$_SESSION['userID']."' AND status='0'"; $query1 = mysql_query($sql1)or die(mysql_error()); while ($res1 = mysql_fetch_array($query1)) { //echo $res1['sessionID']."<br>"; echo "<script type='text/javascript'>openChat(\"convo.php?sessionID=".$res1['sessionID']."\", \"Convo\");</script>"; } // selects all users //$sql = "SELECT * FROM `users`"; $sql = "SELECT * FROM `users` where online_status='1'"; $query = mysql_query($sql); ?> Here is our 'Friends List':<br /> <br /> <?php //echo all users with chat now links while($result = mysql_fetch_array($query)) { echo "<a href='javascript: openChat(\"startchat.php?userID=".$result['userID']."\", \"Convo\")'>".$result['username']."</a> <br>"; } ?> i hope for greatful help. regards, Ganesanji Quote Link to comment Share on other sites More sharing options...
FezEvils Posted December 2, 2008 Share Posted December 2, 2008 hello there... just paste this copy in your coding if you have popup and need to reload the main page.. it will close your popup and refresh top page echo "<script>window.close();top.opener.window.location.reload();</script>"; Quote Link to comment Share on other sites More sharing options...
ganesanji Posted December 2, 2008 Author Share Posted December 2, 2008 hi FezEvils, Thanks for the quick reply. I dont want to close the popup window and open it for every refresh. If there is any ajax page refreshment please help me... thanks a lot... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.