forked from IBM-Cloud/php-mysql
-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.php
executable file
·65 lines (54 loc) · 1.37 KB
/
index.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
<?php
/* Store index page
*
* This script depends on the following code in .htaccess:
* <IfModule mod_rewrite.c>
* RewriteEngine on
* RewriteCond %{REQUEST_FILENAME} !-f
* RewriteCond %{REQUEST_FILENAME} !-d
* RewriteRule ^ index.php [L]
* </IfModule>
*
* Place the "static" and "views" directories in the root
* along with this script and the above .htaccess file.
*/
include('db.php');
include('vars.php');
//Query the DB
global $mysqli;
$strsql = "select * from stock";
if ($result = $mysqli->query($strsql)) {
// printf("<br>Select returned %d rows.\n", $result->num_rows);
while ($row = $result->fetch_object()) {
$items[] = clone $row;
}
$result->close();
} else {
echo "Failed to query the database!";
}
$mysqli->close();
$lll_route = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
if (isset($_GET['id'])) {
$item = $items[$_GET['id'] - 1];
}
if (file_exists("views/$lll_route.tpl")) {
ob_start();
require_once("views/$lll_route.tpl");
$lllpage = ob_get_contents();
ob_end_clean();
echo $lllpage;
} elseif (($lll_route == "") || ($lll_route == "/")){
ob_start();
require_once("views/home.tpl");
$lllpage = ob_get_contents();
ob_end_clean();
echo $lllpage;
} else {
echo "\"$lll_route\" page not found";
ob_start();
require_once("views/home.tpl");
$lllpage = ob_get_contents();
ob_end_clean();
echo $lllpage;
}
?>