Re: Real-time database monitor



On May 8, 8:15 am, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@xxxxxxxxxxxxxxxx> wrote:
Justin Voelker schreef:



I have built a php website with a messaging system where users of a
website can send messages to each other and they will appear in the
other users inbox for viewing next time they log in. In a bar at the
top of the page it says "Inbox (0)" if they have no new messages and,
yup, you guessed it "Inbox (2)" if they have two waiting messages. If
someone sends them a message while they are sitting on some page of
the website I would like the counter to increase. Each time someone
sends a message it creates a new record in a single table in the
database. What I am looking for is a way to monitor that database and
find any records with "msg_to" equal to the user id of the person
logged in and "msg_unread" equal to '1.' Right now the mysql query
runs each time a page is loaded so they would be notified then but I
would like it to somehow update the inbox number while they sit on a
page. Does anyone have any ideas? I was told in the comp.lang.php
group that AJAX might be able to help and that I should check this
group. Thank you in advance for your help!

Hi,

I saw you posting in comp.lang.php.
Yes, XMLHttpObject (AJAX) is a good solution for this.

Be aware however that this only works for visitors with JavaScript
enabled. While this is the vast majority, it isn't 100%.
(I keep hearing different percentages, but most are over 90%)

If you decide to do it with AJAX, then this is a good place to start:http://www.w3schools.com/ajaxbut many other resources exist.

If you want it to work for the world at large (= also for those without
JavaScript), you might want to use a frame or an IFrame.
In this IFrame you place your inbox thingy.
You can use META tags in the HTML document to order it to refresh every
X seconds.

Using AJAX will look smoother than using a refreshing IFrame, because
the page in the IFRame must refresh every X seconds, while AJAX will
only update some content on your page (No IFrames needed).

Hope that helps.

Regards,
Erwin Moller

Thank you for the great help! Because of the nature of the website
and the other various tools available to the users, they must have
javascript enabled to even view the site (the entire site is based
around a good map which needs js). I looked at the w3schools ajax and
I think I understand their examples bt I do have one more question. I
have a limited knowledge of javscript (just enough to be dangerous).
I see in the w3schools examples they reply on the "onchange" event of
a dropdown. What would I need to do since I can't user an "onchange"
event or anything else that requires user interaction? My only
thought is something that executes the command every X seconds, but
wouldn't that cause a lot of server load if there are lots of users?
If this is what I need to do, what code would I use. Thank you again
for the wonderful help!
.



Relevant Pages

  • Re: Real-time database monitor
    ... other users inbox for viewing next time they log in. ... XMLHttpObject (AJAX) is a good solution for this. ... you might want to use a frame or an IFrame. ... And yes, if X is small, you create a lot of work for the server. ...
    (comp.lang.javascript)
  • Re: Real-time database monitor
    ... other users inbox for viewing next time they log in. ... XMLHttpObject (AJAX) is a good solution for this. ... In this IFrame you place your inbox thingy. ...
    (comp.lang.javascript)
  • Re: Real-time database monitor
    ... On May 8, 9:36 am, Erwin Moller ... other users inbox for viewing next time they log in. ... XMLHttpObject (AJAX) is a good solution for this. ... And yes, if X is small, you create a lot of work for the server. ...
    (comp.lang.javascript)
  • Real-time database monitor
    ... I have built a php website with a messaging system where users of a ... website can send messages to each other and they will appear in the ... other users inbox for viewing next time they log in. ... What I am looking for is a way to monitor that database and ...
    (comp.lang.javascript)
  • Re: Not Receiving my website emails in my Windows Mail Inbox.
    ... Are the missing messages found in the inbox of your personal account's webmail page? ... hosting with Network Solutions. ... confirmed that I have set up the protocols so that all my website emails are ... when I went online to Net. ...
    (microsoft.public.windows.vista.mail)