<?php session_start(); ?>
<?php
   include ("dbcon.php");
?>
<!DOCTYPE html>
<html>
 <head>
  <title></title>
  <script type="text/javascript">
    $(document).ready(function() {
       $('.btnupdt a').click(function(e){
          e.preventDefault(); // prevent the A target from being followed
          var data = new Array(); // prepare some data storage
          $('table#display tr').each(function() {
             var id =  $("td:nth-child(1)", this).text(); 
             var qty = $("select[name='ratelist']", this).val(); 
             var price = $("select[name='ratelist'] :selected", this).data("cost"); 
             data[data.length] = {id: id, qty: qty, price: price}
          });
          $.ajax({
            type: 'POST',
            url: 'updtdata.php',
            data: { records: data }
          })
          .done( function(data) {
            console.log(data);
          })
          .fail( function(jqXHR, textStatus, errorThrown) {
            console.log(textStatus);
          });
       });
    });
  </script>
  </head>
  <body>
   <div class="btns">
     <div class="btnupdt">	<!-- Update all records back to database -->
        <a href="#"><img src="images/btnupdtcart.jpg" alt="" class="shw_updtbtn" /></a>
     </div>				
   </div>
   <div class="disp_recs">
    <?php
     ........
     ........
     ........
     ........
    <?php } ?>
    <?php 
      mysqli_free_result($retrv);
      mysqli_free_result($result);
    ?>
  </div>
 </body>
</html>
<?php mysqli_close($connection); ?>