title: how to get the current added in the table without getting all the data
body: <p>guys im trying to make a simple commenting system, that when i click the submit the fields will automatically save in the database then fetch it using ajax. but im getting all the data repeatedly instead of getting the recently added data in the database here is the code:</p>
  
  <pre><code> &lt;div id="wrap-body"&gt;    
    &lt;form action="" method="post"&gt;
    &lt;input type="text" name="username" id="username"&gt;
    &lt;input type="text" name="msg" id="msg"&gt;
    &lt;input type="button" id="submit" value="Send"&gt;
   &lt;/form&gt;
   &lt;div id="info"&gt;
   &lt;/div&gt;
   &lt;/div&gt; 
  &lt;script&gt;
   $(document).ready(function (){
  $('#submit').click(function (){
   var username = $('#username').val();
    var msg = $('#msg').val();
    if(username != "" &amp;&amp; msg != ""){
         $.ajax({
                    type: 'POST',
                    url: 'get.php',
                    dataType: 'json',
                    data:{ 'username' : username , 'msg' : msg},
                    success: function (data){
                      var ilan=data[0].counter;
                      var i = 0;
                        for(i=0;i&lt;=ilan;i++){
                         $('#info').append("&lt;p&gt; you are:"+data[i].username+"&lt;/p&gt; &lt;p&gt; your message  is:"+data[i].mesg);
                       }
                    }
                });
       }
       else{
        alert("some fields are required");
       }
   });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>   &lt;?php
     $host='localhost';
     $username='root';
     $password='12345';
     $db = 'feeds';
  
      $connect = mysql_connect($host,$username,$password) or die("cant connect");
      mysql_select_db($db) or die("cant select the".$db);
  
      $username = $_POST['username'];
      $msg = $_POST['msg'];
  
      $insert = "INSERT INTO info(user_name,message) VALUES('$username','$msg')";
      if(@!mysql_query($insert)){
        die('error insertion'.mysql_error());
    }
      $get = "SELECT * FROM info ";
      $result=mysql_query($get)or die(mysql_error()); 
      $inside_counter =   mysql_num_rows($result);
      $data=array();
      while ($row = mysql_fetch_array($result))
     {
    $data[] = array(
      'username'=&gt;$row['user_name'],
      'mesg'=&gt;$row['message'],
      'counter'=&gt;$inside_counter
     );
     }
      echo json_encode($data);
      ?&gt;
  </code></pre>