Note that there are some explanatory texts on larger screens.

plurals
  1. PORun PHP every 15 seconds and notify user when database changes
    text
    copied!<p>I'm building an app with JQuery Mobile. I have a page called list.php which gets data from server with PHP. I need the script to run every 15 seconds and notify user if there are changes in database. I am beginner with PHP and Javascript so I have no idea how to do this or if it is even possible. </p> <p>This is the code I'm currently using. </p> <pre><code>&lt;?php $number = $_GET['number'] ; mysql_connect('localhost','username','password'); $link = mysql_connect('localhost', 'username', 'password'); if (!$link) { die('Could not connect: ' . mysql_error()); } //specify database mysql_select_db("database") or die("Unable to select database"); // Build SQL Query $query = "select * from table where tablenumber = \"$number\" and state = 0 order by time"; $result = mysql_query($query) or die("Couldn't execute query"); ?&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;title&lt;/title&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" /&gt; &lt;script src="http://code.jquery.com/jquery-1.6.4.min.js"&gt;&lt;/script&gt; &lt;script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div data-role="page"&gt; &lt;div data-role="header" &gt; &lt;h1&gt;Transpanel&lt;/h1&gt; &lt;/div&gt; &lt;div data-role="content"&gt; &lt;div data-role="collapsible-set"&gt; &lt;?php // display the results returned while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { ?&gt; &lt;div data-role="collapsible" data-theme="b" data-content-theme="d"&gt; &lt;h3&gt;&lt;?= $row["OSO"] ?&gt;&lt;/h3&gt; &lt;p&gt;&lt;?=$row["AIKA"]?&gt;&lt;p&gt; &lt;/div&gt; &lt;?php } ?&gt; &lt;/div&gt; &lt;/div&gt;&lt;!-- /content --&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

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