How do I automatically update MySQL queries with JavaScript?
I was looking at the site and found something that helped me just put it on my site and when I went to see the server processes the second file query.php was opening more than 150 processes ( leaving the server super slow ) is there any more practical way to solve my problem?
<script type="text/javascript">
function doRefresh(){
$("#contagem").load("consulta.php");
}
$(function() {
setInterval(doRefresh, 100);
});
</script>
Query.php file
<?php
require_once "config.php";
$data = mysql_fetch_array(mysql_query("SELECT * FROM teste WHERE ativo='1' ORDER BY RAND() LIMIT 1;"));
$t = time() - $data['tempo'];
echo "<font color='green'><h1>Tempo: $t</h1></font>";
mysql_close($mysql); ?>