We have a PHP page with lots of queries to a mySQL database.
The web page delivers a webcast stream which can be any one of 2 stream types ...
- test mode stream
- live stream
From the back end admin area, we can toggle from test (status value=1) to live (status value=2).
When a user logs in to view the webcast, the page queries the database to check the status of the webcast at the time the user logs in and ...
- if in TEST mode it will return 'value=1' which then displays the test webcast stream
- if in LIVE mode it will return 'value=2' which then displays the live webcast stream
When it is time to go live, the administrator toggles to live mode, changing the webcast status from 'test' (value=1) to 'live' (value=2).
What we need is for the page to regularly query the database to identify when that change is made.
But we don't want the whole page to refresh because that will then restart the test webcast.
Basically we want to know when the result changes from '1' to '2' so that we can change the webcast to show the live feed.
Of course, once it shows the live stream (value=2) then we can stop running the queries.
The code we are using is ...
// get webcast details
$sql_webcast = "SELECT * FROM webcasts WHERE id='$wid' AND code='$code'";
$result_webcast = mysql_query($sql_webcast);
$row_webcast = mysql_fetch_array($result_webcast);
$stream = TEST STREAM;
$stream = LIVE STREAM;