-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
108 lines (88 loc) · 2.39 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
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
<?php
// DB Connection
require_once 'db.php';
session_start() ;
function isAdmin() {
return $_SESSION["user"]["role"] == 2 ;
}
?>
<?php
require_once 'header.php';
?>
<h2>Homepage</h2>
<div style="float:left; ">
<b>Categories</b><br>
<?php
try {
$sql = "select DISTINCT category,categoryname from product";
$stmt = $db->query($sql) ;
if ( $stmt->rowCount() > 0) {
foreach ( $stmt as $item) {
echo '<tr>' ;
echo "<td><a href='category.php?id={$item['category']}&name={$item['categoryname']}'>{$item['categoryname']}</a><br></td>" ;
echo '</tr>' ;
}
} else {
echo '<tr><td>No records yet.</td></tr>' ;
}
} catch( Exception $ex) {
echo '<p>Query error ' . $ex->getMessage() . '</p>' ;
}
?>
</div>
<div style="float:left; margin-left: 50px; width: 500px;">
<b>Promotional Products</b><br>
<div class="slideshow-container">
<?php
try {
$sql = "select * from product";
$stmt = $db->query($sql) ;
if ( $stmt->rowCount() > 0) {
foreach ( $stmt as $item) {
if ($item['promotional']==1) {
echo '<div class="mySlides fade">';
echo '<div class="text">'.$item['name'].'</div>';
echo "<a href='product.php?id=".$item['id']."'><img src='{$item['photo']}' style='width:100%'></a>";
echo '</div>';
}
}
} else {
echo '<tr><td>No records yet.</td></tr>' ;
}
} catch( Exception $ex) {
echo '<p>Query error ' . $ex->getMessage() . '</p>' ;
}
?>
</div>
<br>
<div style="text-align:center">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
</div>
<br>
<div style="clear:both"></div>
<script>
var slideIndex = 0;
showSlides();
function showSlides() {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex> slides.length) {slideIndex = 1}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
setTimeout(showSlides, 2000); // Bu alandan resimlerin geçiş süresini değiştirebilirsiniz.
}
</script>
<?php
require_once 'footer.php';
?>