Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Or you can use a real time framework. I work for Realtime.co and we do just that.</p> <p>You can get a free license at <a href="http://www.realtime.co" rel="nofollow">www.realtime.co</a>, get the PHP API at <a href="http://www.xrtml.org/downloads_62.html#pubsub%3aphp" rel="nofollow">http://www.xrtml.org/downloads_62.html#pubsub:php</a> and use the following code for the page that should broadcast the information (your administration page, for example). Note: this code is the same you can find at Github for the ORTC example (<a href="https://github.com/RTWWorld/pubsub-examples/tree/master/PHP" rel="nofollow">https://github.com/RTWWorld/pubsub-examples/tree/master/PHP</a>) adapted for your needs.</p> <pre><code>&lt;?php error_reporting(E_ALL); session_start(); require('./ortc.php'); /* -------------------- */ /* REPLACE THESE VALUES */ /* -------------------- */ $URL = 'http://ortc-developers.realtime.co/server/2.1'; $AK = 'YOUR_APPLICATION_KEY';// your realtime.co application key $PK = 'YOUR_APPLICATION_PRIVATE_KEY';// your realtime.co private key $TK = 'YOUR_AUTHENTICATION_TOKEN';// token: could be randomly generated in the session $CH = 'MyChannel'; //channel $ttl = 180; $isAuthRequired = false; $result = false; /* -------------------- */ /* END */ /* -------------------- */ // ORTC auth // on a live usage we would already have the auth token authorized and stored in a php session // Since a developer appkey does not require authentication the following code is optional if( ! array_key_exists('ortc_token', $_SESSION) ){ $_SESSION['ortc_token'] = $TK; } $rt = new Realtime( $URL, $AK, $PK, $TK ); // Your query $tot_clicks6 = $db-&gt;FetchArray($db-&gt;Query("SELECT SUM(visits) AS sum_visits FROM surf")); if($isAuthRequired){ $result = $rt-&gt;auth( array( $CH =&gt; 'w' ), $ttl );//post authentication permissions. w -&gt; write; r -&gt; read echo 'authentication status '.( $result ? 'success' : 'failed' ).'&lt;br/&gt;'; } if($result || !$isAuthRequired){ $result = $rt-&gt;send($CH, tot_clicks6['sum_visits'], $response); echo ' send status '.( $result ? 'success' : 'failed' ).'&lt;br/&gt;'; } ?&gt; </code></pre> <p>On the receiver page, you'll need to receive the data, using JavaScript and display it. For this example I'm just alerting the user with the data.</p> <pre><code>&lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;script src="http://code.xrtml.org/xrtml-3.2.0.js"&gt;&lt;/script&gt; &lt;script&gt; var appkey = 'YOUR_APPLICATION_KEY'; var url = 'http://ortc-developers.realtime.co/server/2.1'; var authToken = 'YOUR_AUTHENTICATION_TOKEN'; var channel = 'MyChannel'; xRTML.load(function(){ xRTML.Config.debug = true; xRTML.ConnectionManager.create({ id: 'myConn', appkey: appkey, authToken: authToken, url: url, channels: [ {name: channel} ] }).bind({ message: function(e) { alert(e); } }); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>With this code you won't need to use AJAX or anything like that. You'll be able to push your data to browsers instead.</p> <p>Hope it helps!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload