Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a php program that will query the supermarket database and display the fol

ID: 657535 • Letter: W

Question

Write a php program that will query the supermarket database and display the following results:

From the transaction table, for each hour of the day (represented by trans_time), show the total of the sales_value column for that hour and find and display the most sold item for that hour of the day.

Notes:

a. The trans_time column in that table is an integer in the range 0 to 2359, with 0 representing midnight and 2359 representing 23:59 (11:59pm). The time values from 0 to 59 represent 00:00 - 00:59 or 12:00 midnight to 12:59 am; The values from 100 to 159 represent 1:00am to 1:59am; etc.

b. You might find the integer divide operation div useful.

c. It might be easier to write a couple (or more) smaller queries and combine their results for each row of output.

d. Your program should have 24 rows of output -- 0, 1, 2, ... 22, 23 (or midnight, 1:00am, 2:00am, ... 10:00pm, 11:00pm)

Willing to pay for help not just the answer....I have the database on mysql.....i can upload

Explanation / Answer

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "MyDB";

$conn = new mysql($servername, $username, $password, $dbname);

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT id, username, totalsales, solditems FROM Supermarket";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " userame: " . $row["totalsales"]. " " . $row["solditems"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote