-
Notifications
You must be signed in to change notification settings - Fork 0
/
employee_sales.php
34 lines (28 loc) · 937 Bytes
/
employee_sales.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
include "config.php"; // Include your database connection configuration
$sql = "SELECT E.E_ID, CONCAT(E.E_FNAME, ' ', E.E_LNAME) AS Employee_Name, SUM(S.TOTAL_AMT) AS Total_Sales_Amount
FROM employee E
LEFT JOIN sales S ON E.E_ID = S.E_ID
GROUP BY E.E_ID, Employee_Name
ORDER BY Total_Sales_Amount DESC";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo '<table>';
echo '<tr>';
echo '<th>Employee ID</th>';
echo '<th>Employee Name</th>';
echo '<th>Total Sales Amount</th>';
echo '</tr>';
while ($row = $result->fetch_assoc()) {
echo '<tr>';
echo '<td>' . $row['E_ID'] . '</td>';
echo '<td>' . $row['Employee_Name'] . '</td>';
echo '<td>' . $row['Total_Sales_Amount'] . '</td>';
echo '</tr>';
}
echo '</table>';
} else {
echo 'No data found.';
}
$conn->close();
?>