I have a table that has the orders and I want when each order has entered the database I want it to be displayed in the table without refreshing the page and without pressing any button. Here is the code in PHP and HTML:
<?php
require_once '../core/init.php';
if(!is_logged_in()){
header('Location: login.php');
}
include 'includes/head.php';
include 'includes/navigation.php';
?>
<!-- Orders To Fill -->
<?php
$txnQuery = "SELECT t.id, t.cart_id, t.first_name, t.last_name, t.description, t.txn_date, t.grand_total, c.items, c.paid, c.shipped
FROM transactions t
LEFT JOIN cart c ON t.cart_id = c.id
WHERE c.paid = 1 AND c.shipped = 0
ORDER BY t.txn_date";
$txnResults = $db->query($txnQuery);
?>
<div class="col-lg-12">
<h4 class="text-center">Orders To Ship <span class="glyphicon glyphicon-list-alt" style="font-size:23px;"></span></h4>
<table class="table table-sm table-bordered table-striped">
<thead>
<th></th><th>Name</th><th>Description</th><th>Total</th><th>Date</th>
</thead>
<tbody>
<?php while($order = mysqli_fetch_assoc($txnResults)): ?>
<tr>
<td><a href="orders.php?txn_id=<?=$order['id'];?>" class="btn btn-sm btn-info">Details <span class="glyphicon glyphicon-info-sign"></span></a></td>
<td><?=$order['first_name']. ' '.$order['last_name'];?></td>
<td><?=$order['description'];?></td>
<td><?=money($order['grand_total']);?></td>
<td><?=pretty_date($order['txn_date']);?></td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
Please, how to do that in AJAX?