How to preview values of dynamically generated fields in rows of a table-include a row for data returned from database

How to preview values of dynamically generated fields in rows of a table-include a row for data returned from database

I'm trying to build a form on my website where users can make orders. More fields can be generated dynamically for more orders and a table is displayed previewing the orders so far. However, i intend to incorporate a functionality where costs (and then maybe the total cost too) of each product ordered is displayed on a td on each row of the preview table along with the product and the quantities ordered. I have a php page which echoes the cost of each product as selected from database, and then fetch this with an ajax call. Please see my attempt on jfiddle
Now i want each product cost (as fetched from the database via the php page) to be displayed on corresponding rows under the thead 'Cost' in my fiddle.
Here's content of my php page: 
  1. <?php
  2.       require("conn.php");
  3.       $type = $_POST['type'];
  4.       $sql = mysqli_query($conn, "SELECT cost from product_cost WHERE product ='$type'");
  5.             if ($sql){
  6.                   while ($row = mysqli_fetch_row($sql)){
  7.                         $cost = $row[0];
  8.                         echo $cost;
  9.                   }
  10.             }
  11. ?>
Thanks for your anticipated reply.