Dayo Posted January 19, 2011 Share Posted January 19, 2011 Hiya is it possable to show an element once a table in the DB has been altered ie user 1 clicks send and user2 automaticly gets a popup saying you have a new meaasage! Quote Link to comment Share on other sites More sharing options...
Sim Posted January 19, 2011 Share Posted January 19, 2011 From what I have read, it would be best to use txt file or some other sort of file rather then a sql DB for something like this. I may be wrong though. Quote Link to comment Share on other sites More sharing options...
Djkanna Posted January 19, 2011 Share Posted January 19, 2011 Yes by checking every so often if a user has a new pm. Quote Link to comment Share on other sites More sharing options...
Sim Posted January 20, 2011 Share Posted January 20, 2011 Was that yes to me or him? Quote Link to comment Share on other sites More sharing options...
Djkanna Posted January 20, 2011 Share Posted January 20, 2011 Him. Ofcourse you could do upon member1 sending the mail to member2, check whether member2 is online (surely you have some form of last action field) then work out a way to send a pop-up to that member, right now I cannot actually think but Google may be useful for this. Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted January 20, 2011 Share Posted January 20, 2011 Checking a DB is fine... if the DB is small, the best choice is to use a MySQL memory table if possible, however keep in mind memory tables do not keep the data after a reboot and backups don't store the data neither. So it must be like just a pure "cache" or "notify" area. Using text files is also ok, but then keep the file very small. Quote Link to comment Share on other sites More sharing options...
Dayo Posted January 20, 2011 Author Share Posted January 20, 2011 The pm thing was just an example what I really wanted was to show when user 1 is online and user 2 logsin it says user 2 is online. I said upon SQL update as I can do a simple query in the user database to find any person who has logged in within x amount of seconds and is a friend of the user I'm trying to make my game more social rather then the constant click click click Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted January 20, 2011 Share Posted January 20, 2011 You should look at XMLHttpRequest for that Dayo. Which is basically sending a request to the server in this case query the db who is online and then sending the result back to the webpage. Quick google on that will lead you here http://forums.devnetwork.net/viewtopic.php?t=34665 Quote Link to comment Share on other sites More sharing options...
Dayo Posted January 20, 2011 Author Share Posted January 20, 2011 Thanks rulerofzu I'll try it when I get home I did do he 30mins of googling before posting but didn't really know what to search for as I very dearly use Ajax and normally that is a premade script :) Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted January 20, 2011 Share Posted January 20, 2011 XMLHttpRequest will work for FF and Chrome but not for IE if I remember right... I can send you a snippet how to do it if you need to or other option is to use JQuery for such things. Other option is to use an IFRAME and refresh it. You can either make it directly visible such that you show stuff there or you make it invisible and use JS to grab the content from within the IFRAME. Quote Link to comment Share on other sites More sharing options...
Dayo Posted January 20, 2011 Author Share Posted January 20, 2011 DJ has sent me a jquery way to do it but ild like to see how you would do it Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted January 20, 2011 Share Posted January 20, 2011 That's the base JS code I use function ajaxCall(url) { var http = null; try { http = new XMLHttpRequest(); } catch (e) { try { http = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e2) { http = false; } } if (!http) { return false; } http.open("GET", url); http.onreadystatechange = function() { if (http.readyState == 4) { // Do something with http.responseText } } http.send(null); return false; } call the function function with the URL you want, and in the "// do something" area parse the text or use it... 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.