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:
- <?php
- require("conn.php");
- $type = $_POST['type'];
- $sql = mysqli_query($conn, "SELECT cost from product_cost WHERE product ='$type'");
- if ($sql){
- while ($row = mysqli_fetch_row($sql)){
- $cost = $row[0];
- echo $cost;
- }
- }
- ?>
Thanks for your anticipated reply.