-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgetProductInfo.php
More file actions
41 lines (31 loc) · 826 Bytes
/
getProductInfo.php
File metadata and controls
41 lines (31 loc) · 826 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
38
39
40
41
<?php
include('./php/globals.php');
// Open new connection
$conn = open_db_conn();
$getProductInfo = "SELECT * from visitcount ORDER BY visitcounter DESC";
if ($conn->connect_error)
{
die("Failed!");
}
$result = mysqli_query($conn,$getProductInfo);
$count = mysqli_num_rows($result);
$productinfo= array();
while($row = mysqli_fetch_array($result))
{
array_push($productinfo, array(
"prodID"=>$row['prodID'],
"prodCat"=>$row['prodCat'],
"prodCatName"=>$row['prodCatName'],
"visitcounter"=>$row['visitcounter']
));
}
if($count > 0)
{
print(json_encode($productinfo));
}
else
{
print("No products Found");
}
mysqli_close($conn);
?>