tags:

views:

47

answers:

3

I've been using an HTTP POST to a php file to change entries in a given MySQL database. Essentially, the second the value changes, I would like the user that is viewing the database table to be notified. For now my temporary solution is to auto refresh a page displaying the table to keep it updated but I feel like there has to be a more efficient way of going about this.

A: 

Do you really have to update it in the same second? It looks like a server killer feature.
Read about Comet, maybe it will be useful.

Naktibalda
A: 

IIRC mysql_affected_rows() will only report instances where the data has changed (i.e. if you try to update a row to its current values then it won't give an error).

I find it hard to believe that you've got someone watching a screen waiting for an update to occur - maybe a better approach would be to add a timestamp field to the record - but note that if you do this, and in the absence of other checks, the record will always update - to prevent make sure at least one of the fields has changed in the update.

C.

symcbean
Without trying to be too specific, I want a user who has access to one particular data entry to be alerted or notified the instant a given value changes.
Then look for a solution where you can describe what records have changed and **not** been notified
symcbean
A: 

When I had to do this, I created a one-row table containing the last time any relevant part of the database was updated. Then the once-per-second activity was confined to seeing if the contents of that one-row table showed newer than the local value; if so, refresh.

The one-row table could be updated via triggers from any table containing relevant facts, or from the application, as you think best.

Brian Hooper