File: /home/bigisxfd/public_html/cowork/product_sold_report.php
<?php
// Include necessary files
include_once("header.php");
include_once("sidebar.php");
?>
<section>
<div class="column">
<h2>Products Sold</h2>
<?php
// Get selected date or use the current date as default
$selectedDate = isset($_GET['date']) ? $_GET['date'] : date("Y-m-d");
// Query to retrieve products sold for the selected date with the specified format
$sql = "SELECT items
FROM Orders
WHERE DATE_FORMAT(date, '%Y-%m-%d') = '$selectedDate'
AND payment_status = 1
AND items REGEXP '^[0-9]+ x \\(.*\\)$'";
$result = mysqli_query($conn, $sql);
echo '<form method="get" action="">
Select Date: <input type="date" name="date" value="' . $selectedDate . '" onchange="this.form.submit()">
</form>';
if (mysqli_num_rows($result) > 0) {
// Output table header
echo "<table border='1'>
<tr>
<th>Products Sold</th>
</tr>";
// Output data
while ($row = mysqli_fetch_assoc($result)) {
echo "<tr>
<td>" . $row['items'] . "</td>
</tr>";
}
echo "</table>";
} else {
echo "No records found for the selected date and payment status.";
}
?>
</div>
</section>
</body>
</html>