-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
83 lines (65 loc) · 2.01 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
session_start();
$title = "M Your Design";
include_once "classes/lib_project1.php";
require_once "classes/header.inc.php";
require_once 'classes/DB.class.php';
$display = "";
//$db = new DB();
/*
* Display Products on Sale
*
*/
echo "<br>";
echo "<div class = 'SaleProductsTag'><h3>Discounted Products</h3></div>";
echo "<div class = 'saleProducts'>";
$saleProducts = $db->getAllObjectsOfProductsOnSale();
foreach ($saleProducts as $sale_product) {
echo "{$sale_product->getAllSaleProducts()}";
}
echo "</div>";
/*
* For displaying products which are available for selling
* (Catalog Products)
*/
//Pagination For Catalog Products --Starts
//User Input
$page = $_GET['page'];
$perPage = 5;
//Positioning
$start = ($page > 1) ? ($page * $perPage) - $perPage :0;
//pages
$total = $db->getTotalCountCatalog();
$pages = ceil($total/$perPage);
$toPage = (($start + $perPage) > $total) ? $total : $start + $perPage;
echo "<div class = 'catalogProductsTag'><h3>Catalog Products</h3></div>";
echo "<div class = 'showresults'>Showing results " . $start . " - " . $toPage ." of " . $total . ".</div>";
echo "<div class = 'catalogProducts'>";
$products = $db->getAllObjectsOfCatalogProducts( $start , $perPage );
foreach ($products as $product) {
echo "{$product->getAllCatalogProducts()}";
}
echo "</div>";
///*
// * When Add to Cart Button is hit Set Session and add the product to Cart table of database
// */
//if (isset($_POST['product_addToCart'])) {
// handleAddToCart($db);
//}
?>
<div class = 'pagination'>
<table class = 'paginationTable'>
<tr>
<?php for( $x = 1; $x <= $pages; $x++ ) { ?>
<td>
<a href="?page= <?php echo $x; ?>" <?php if ($page == $x) { echo "class = 'selected'";}?>>
<?php echo "\t $x \t"; ?>
</a>
</td>
<?php } ?>
</tr>
</table>
</div>
<?php
require_once PATH_HOME. "classes/footer.php"
?>