-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
37 lines (30 loc) · 780 Bytes
/
functions.php
File metadata and controls
37 lines (30 loc) · 780 Bytes
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
<?php
function connect()
{
$c = new mysqli("localhost", "root", "", "vrs");
if($c->connect_errno != 0)
return $c->connect_error;
else
$c->set_charset("utf8mb4");
return $c;
}
function getAllCars()
{
$c = connect();
$cars = $c->query("select * from cars order by rand()");
while($car = $cars->fetch_assoc())
{
$car_details[] = $car;
}
return $car_details;
}
function getCarsByBrand($brand)
{
$c = connect();
$cars = $c->query("select * from cars where brand='$brand'");
while($car = $cars->fetch_assoc())
{
$car_details[] = $car;
}
return $car_details;
}