I'm using bootstrap modal and currently i'm stuck with displaying the values to modal.
here is the html when the user will click view
<a data-toggle="modal" data-id="<?php echo $row33['bicycle_id']; ?>" href="#myModal" class="Buto" >view</a>
then i used jquery-ajax to pass the value of data-id to execute a query in php
$(document).on("click",".Buto", function () {
var dataID = $(this).data('id');
$.ajax({
url: 'getId.php?id=' + dataID,
type:'GET',
dataType: 'json',
context: this,
success: function(values)
{
values = $.parseJSON(values);
$('.table-responsive #pname').html(values.name);
$('.table-responsive #pprice').html(values.price);
$('.table-responsive #pdescription').html(values.description);
}
});
});
here is the getId.php file
<?php
include 'includes/connection.php';
$modalDataId = $_GET['id'];
$resu = mysqli_query($conn,"SELECT * FROM bicycle WHERE bicycle_id = $modalDataId");
while ($row7 = mysqli_fetch_assoc($resu)){
$values['name'] = $row7['name'];
$values['price'] = $row7['price'];
$values['description'] = $row7['description'];
}
echo json_encode($values);
?>
then the modal where the values should be displayed
<div class="modal-body">
<div class="table-responsive" id = "div1" style = " width: 100%; margin-right: 10%; background-color: white;">
<table id = "" align = "center" class="table table-hover table-striped demo2" style = "table-layout:fixed;"> <thead style = "">
<tr style = "background-color: #428bca; color: white;">
<th class="col-sm-3">BIKE NAME</th>
<th class="col-sm-3" >SRP</th>
<th class="col-sm-3" >DETAILS</th>
</tr>
</thead>
<tbody id="myTable">
<tr style = "text-align: center;" data-toggle="modal" data-id="" data-target="#orderModal">
<td id="pname"></td>
<td id="pprice"></td>
<td id="pdescription"></td>
</tr>
</tbody>
</table>
</div>
</div>