title: Ajax/php getting newest data notification
body: <p>I'm having a little trouble fetching the newest bit of data. All I'm wanting is to find if there is any new data in the database and print the number of records back into my page. I have the ajax working and it has the last notification_id that it sends over to the php. I just need to get the php to select any new data, send it back and print it out.</p>
  
  <p>I haven't yet tried polling, but will look into it when I have this working and understand it a bit better.</p>
  
  <pre><code>&lt;?  $call="SELECT * FROM notifications WHERE notification_targetuser='$user1_id' AND notification_status=1 ORDER BY notification_id DESC LIMIT 1";
          $chant=mysqli_query($mysqli,$call) or die(mysqli_error($mysqli));
              while($notification_id=mysqli_fetch_array($chant))
              {
                  ?&gt;
              &lt;script type="text/javascript"&gt;
  setInterval(function(){
  
  
    var notification_id="&lt;?php echo $notification_id['notification_id'] ;?&gt;"
  
  $.ajax({
  type: "GET",
  url: "viewajax.php?notification_id="+notification_id,   
  dataType:"json",
  cache: false,
  success: function(data){
  $(".mess"+notification_id).prepend("&lt;span class'mess' id='mes'&gt;"+response['notification_id']+"&lt;/span&gt;");
  
  }
  });
  },20000);
  
  &lt;/script&gt;
  &lt;? }?&gt;
  </code></pre>
  
  <p>echo '';</p>
  
  <p>PHP viewajax.php - changed it to JSON - but getting {"notification_id":null} in the response</p>
  
  <pre><code>   &lt;?php
  session_start();
   include"database.php";
  
  if(isset($_GET['notification_id']))
  {
  $id=$_GET['notification_id'];
  $user1_id=$_SESSION['id'];
  $json = array();
  $com=mysqli_query($mysqli,"select notification_id from notifications where notification_id&gt;'$id' AND notification_targetuser='$user1_id' AND notification_status=1");
  
  $resultArr = mysqli_fetch_array($com);
  $json['notification_id'] = $resultArr['notification_id'];
  mysqli_free_result($com);
  
  
  echo json_encode($json);
   }?&gt;
  </code></pre>