-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckdate.php
119 lines (76 loc) · 2.84 KB
/
checkdate.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Yurts</title>
<link rel="stylesheet" href="css/pacific.css">
</head>
<body id="wrapper">
<header>
<h1>RentAll </h1>
</header>
<div class="row">
<div class="column-left">
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="cars.php">Cars</a></li>
<li><a href="owners.php">Owners</a></li>
<li><a href="current.php">Current Rentals</a></li>
<li><a href="add.php">Add a Car</a></li>
<li><a href="reservations.php">Rent out</a></li>
<li><a href="myreservations.php">Check Reservations</a></li>
<li><a href="update.php">Update Car</a></li>
<li><a href="check.php">Check Earnings</a></li>
</ul>
</nav>
</div>
<div class="column-right">
<img id="coast" src="images/money.jpg" height="300px;" width="100%" />
<section>
<h2>Earnings by car type between
<?php echo $_POST['sdate']." and ".$_POST['edate']; ?>
</h2>
<?php
function connect(){
$con =mysqli_connect('localhost','root','');
if(!$con)
{
echo 'Not connected';
}
else if(!mysqli_select_db($con,'rental _company'))
{
echo 'Databse not selected';
}
else{
return $con;
}
}
$sd=$_POST['sdate'];
$ed=$_POST['edate'];
$sql="SELECT owners.NAME, cars.TYPE, SUM(reservation_details.AMOUNT) AS EARNINGS from cars INNER JOIN reservations on cars.V_ID=reservations.V_ID INNER join reservation_details on reservation_details.RES_ID=reservations.RES_ID INNER JOIN owners ON cars.O_ID=owners.O_ID WHERE reservation_details.E_DATE BETWEEN '$sd' AND '$ed' GROUP BY cars.TYPE ";
$c=connect();
$res=mysqli_query($c, $sql);
echo "<table>"; // start a table tag in the HTML
echo " <tr>
<th>OWNER</th>
<th>TYPE</th>
<th>EARNINGS</th>
</tr>";
while($row = mysqli_fetch_array($res))
{ //Creates a loop to loop through results
echo "<tr><td>" . $row['NAME'] . "</td><td>" . $row['TYPE'] . "</td><td>" . "$".number_format((float)$row['EARNINGS'], 2, '.', '') . "</td></tr>";}
echo "</table>"; //Close the table in HTML
mysqli_close($c);
?>
</section>
<br /><br />
<footer>
<br />
</footer>
</div>
</div>
<!--The Footer-->
</body>
</html>