This is a very large question that implies a lot of different notions. You should work at different levels (server, client and database) with multiple possibilities each time.
1) client pull
In the client page (user Z), you should send AJAX requests every once in a while (every 1 sec?) and the script on the server side should detect what values have been changed since the last request. This heavily relies on the existence of a timestamp field that is updated using triggers on every SQL insert or update (or delete?).
2) server push
Using websockets, the client (user Z) keeps an open connection to the server. On the server, a process is running constantly in the background and periodically checks the database (every 1 sec?) for updates (again based on timestamps) and sends the difference to the client on the websocket.
If your database does not fix some identifiable timestamp or id or else, you may try to execute an external program using triggers which will probably add another level of complexity.