2025-06-06 17:31:03 +08:00

86 lines
2.0 KiB
PHP

<html>
<head>
<style>
td{
font-size: small;
}
th{
font-size: small;
}
</style>
<link rel="stylesheet" href="./cart.css" type="text/css" />
</head>
</html>
<?php
include "../ConnectDB.php";
// Start the session
session_start();
$username = mysqli_real_escape_string($conn, $_SESSION['username']);
$usertype = mysqli_real_escape_string($conn, $_SESSION['user_type']);
if($usertype == "seller"){
$r = "seller_receipt";
}
else{
$r = "buyer_receipt";
}
$sql = "SELECT * FROM $r WHERE name='$username'";
$result = mysqli_query($conn, $sql);
$row = mysqli_num_rows($result);
if($row <= 0){
echo '<h3>Nothing Here</h3>';
return;
}
echo '<div id="grid">';
for ($i = 0; $i < $row; $i++) {
//get number of columns
$fields = mysqli_num_fields($result);
//Get each row data
while ($row_data = mysqli_fetch_array($result)){
echo '<table id="items">';
//display for each fruit
echo '<tr>';
echo '<th width="20%">Fruit</th>';
echo '<th width="20%">Quantity (kg)</th>';
echo '<th width="20%">Unit price (¥/kg)</th>';
echo '<th width="20%">Retail price (¥)</th>';
echo '</tr>';
//explode details messages to display
$list = explode("|", $row_data['details']);
for($index = 0; $index < count($list); $index++){
if($index % 4 == 0){
echo "<tr>";
echo "<td>".$list[$index]."</td>";
}
else echo "<td>".$list[$index]."</td>";
}
//display for total price and date
echo '<tr style="color: blue;">';
echo '<th></th>';
echo '<th></th>';
echo '<th>Date</th>';
echo '<th>Total price</th>';
echo '</tr>';
echo '<tr style="color: blue;">';
echo '<th></th>';
echo '<th></th>';
echo "<td>".$row_data['date']."</td>";
echo "<td>¥".$row_data['total']."</td>";
echo '</tr>';
echo "</table>";
}
}
echo '</div>';
?>