<table>
<?php
while($ticketdata = mysqli_fetch_array($ticketresults)){
<tr>
<td><a href="#" id="<?php echo $ticketdata['ticketnumber']; ?>" class="view_data" /><?php echo $ticketdata['ticketnumber']; ?></a></td>
<td><?php echo $ticketdata['name']; ?></td>
<td><?php echo $ticketdata['policynumber']; ?></td>
<td><?php echo $ticketdata['registration_number']; ?></td>
<td><?php echo $ticketdata['insuredname']; ?></td>
<td><?php echo $ticketdata['contactnumber']; ?></td>
<td><?php echo $ticketdata['casestatus']; ?></td>
<td>DELETE</td>
</tr>
<?php } ?>
</table>
</body>
</html>
<div id="dataModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Policy Details</h4>
</div>
<div class="modal-body" id="detail">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Ajax Код: -
<script>
$(document).ready(function(){
$('.view_data').click(function(){
var ticket_id = $(this).attr("id");
$.ajax({
url:"select.php",
method:"post",
data:{ticket_id:ticket_id},
success:function(data){
$('#detail').html(data);
$('#dataModal').modal("show");
}
});
});
});
</script>
выберите. php: -
<?php
if(isset($_POST["ticket_id"]))
{
$output = '';
$connect = mysqli_connect("localhost", "root", "", "testing");
$query = "SELECT * FROM table_name WHERE id = '".$_POST["ticket_id"]."'";
$result = mysqli_query($connect, $query);
$output .= '
<div class="table-responsive">
<table class="table table-bordered">';
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td width="30%"><label>S. No</label></td>
<td width="70%">'.$row["ticketnumber"].'</td>
</tr>
<tr>
<td width="30%"><label>Ticket Name</label></td>
<td width="70%">'.$row["name"].' Year</td>
</tr>
';
}
$output .= "</table></div>";
echo $output;
}
?>