<?php session_start(); ?>
<?php
include ("dbcon.php");
?>
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
$(document).ready(function() {
$("select[name='ratelist']").change(function() {
var cost = $("option:selected", this).data('cost');
var currentRow = $(this).parents('tr'); // get the <tr> that contains the changed <select>
$("input[name='i-cost']", currentRow).val(cost); // set the value of 'i-cost' in the currentRow only
});
});
</script>
</head>
<body>
<div class="hdr-div">
<div class="btnupdt"> <!-- Update all records back to database -->
<a href="#"><img src="images/btnupdtcart.jpg" alt="" class="shw_updtbtn" /></a>
</div>
<div class="disp_recs">
<?php
$var = 'rahul@xys.com';
$query = "SELECT user_id FROM user_dtls where u_emailid = '{$var}'";
$retrv = mysqli_query($connection, $query);
$retrvarr = mysqli_fetch_array($retrv);
if (!$retrvarr)
{ die("Database Query failed." . mysqli_error($connection)); }
else {$getid = $retrvarr[0];}
//get details based on id
$pickrecs = "SELECT t_ordid, DATE_FORMAT(tord_dt,'%d-%m-%Y') as label_date, file_path, file_name FROM utmp_orders where user_id = '{$getid}'";
$result = mysqli_query($connection, $pickrecs); ?>
<table id='display'>
<thead>
<tr>
<th>Labels</th>
<th>Creation Date</th>
<th>Total Price ( £ )</th>
<th></th>
</tr>
</thead>
<?php while($resultarr = mysqli_fetch_assoc($result)){ ?>
<tbody>
<tr>
<!--<td style="display:none;"><?php //echo $resultarr["t_ordid"] ?></td>-->
<td><?php echo $resultarr["t_ordid"] ?></td>
<td><?php echo $resultarr["label_date"] ?></td>
<td><?php
$pickrecs = "SELECT rt_qty, rt_cost FROM rate_mast order by rt_qty";
$rtlist = mysqli_query($connection, $pickrecs);
echo "<select name='ratelist' value='' class='rdd'>";
while($rtlistarr = mysqli_fetch_assoc($rtlist)){
echo "<option value = $rtlistarr[rt_qty] data-cost='" . $rtlistarr[rt_cost] . "'>$rtlistarr[rt_qty]</option>";
}
echo "</select>";
?></td>
<td><input type="text" name="i-cost" value="5.95" readonly class="icost"></td>
</tr>
<?php } ?>
</table>
<?php
mysqli_free_result($retrv);
mysqli_free_result($result);
?>
</div>
</body>
</html>
<?php
mysqli_close($connection);
?>