在PHP中更新变量而不刷新

I need to update a variable named $count (in the below code) automatically. When my database update, $count be update immediately because i need to use value of $count in android app so i can't refresh count.php file every time.

<?php
$con=mysql_connect("","","");
mysql_select_db("u607509006_bd1",$con);

$query = "select * from content where status='a'";
$result = mysql_query($query);
$count = mysql_num_rows($result);
echo $count;
mysql_close($con);
?>

Just use a Jquery Ajax Request on the client side like so:

$.ajax({
  url: "path/to/code/file.php" // change this to your path to your code
}).done(function(data) {
  // This is executed after the ajax request is complete
  // data should be the updated value. You can also return other data // types e.g. JOSN
  $('#counter').text(data);
});

JS Fiddle Example: https://jsfiddle.net/anik786/nvkdLhv2/2/