-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.php
178 lines (146 loc) · 6.07 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
include 'header.php';
$header = new header();
$header->render();
?>
<!-- Carousel Start -->
<div class="container-fluid mb-3">
<div class="row px-xl-5">
<div class="col-lg-12">
<div id="header-carousel" class="carousel slide carousel-fade mb-30 mb-lg-0" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#header-carousel" data-slide-to="0" class="active"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item position-relative active" style="height: 430px;">
<img class="position-absolute w-100 h-100" src="img/carousel-1.jpg" style="object-fit: cover;">
<div class="carousel-caption d-flex flex-column align-items-center justify-content-center">
<div class="p-3" style="max-width: 700px;">
<h1 class="display-4 text-white mb-3 animate__animated animate__fadeInDown">Men
Fashion</h1>
<p class="mx-md-5 px-5 animate__animated animate__bounceIn">Provides a variety of fashion choices for men</p>
<a class="btn btn-outline-light py-2 px-4 mt-3 animate__animated animate__fadeInUp" href="shop.php">Shop Now</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Carousel End -->
<!-- Featured Start -->
<!-- Featured End -->
<!-- Categories Start -->
<div class="container-fluid pt-5">
<h2 class="section-title position-relative text-uppercase mx-xl-5 mb-4"><span class="bg-secondary pr-3">Categories</span></h2>
<div class="row px-xl-5 pb-3">
<div class="col-lg-3 col-md-4 col-sm-6 pb-1">
<a class="text-decoration-none" href="#produkpria">
<div class="cat-item img-zoom d-flex align-items-center mb-4">
<div class="overflow-hidden" style="width: 100px; height: 100px;">
<img class="img-fluid" src="img/cat-5.jpeg" alt="">
</div>
<div class="flex-fill pl-3">
<h6>Man</h6>
<small class="text-body">10 Product</small>
</div>
</div>
</a>
</div>
</div>
</div>
<!-- Categories End -->
<!-- Products Start -->
<?php
class Productpria
{
private $id;
private $name;
private $price;
private $image;
public function __construct($id, $name, $price, $image)
{
$this->id = $id;
$this->name = $name;
$this->price = $price;
$this->image = $image;
}
public function getId()
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function getPrice()
{
return $this->price;
}
public function getImage()
{
return $this->image;
}
}
class ProductpriaRepository
{
private $koneksi;
public function __construct($koneksi)
{
$this->koneksi = $koneksi;
}
public function getProductById($productId)
{
$query = "SELECT * FROM tb_produk_pria WHERE id = $productId";
$hasil = mysqli_query($this->koneksi, $query);
$data = mysqli_fetch_array($hasil);
return new Productpria($data['id'], $data['nama_produk'], $data['harga'], $data['gambar']);
}
}
?>
<?php
$koneksi = mysqli_connect("localhost", "root", "", "ecommerce");
$productRepository = new ProductpriaRepository($koneksi);
?>
<div class='container-fluid pt-5 pb-3' id="produkpria">
<h2 class='section-title position-relative text-uppercase mx-xl-5 mb-4'><span class='bg-secondary pr-3'>Produk
Pria</span></h2>
<div class='row'>
<?php for ($i = 1; $i <= 4; $i++) : ?>
<?php $product = $productRepository->getProductById($i); ?>
<div class='col-lg-3 col-md-4 col-sm-6 pb-1'>
<div class='product-item bg-light mb-4'>
<div class='product-img position-relative overflow-hidden'>
<img class='img-fluid w-100' src='img/<?= $product->getImage() ?>' alt='' style='height: 650px; object-fit: cover;'>
<div class='product-action'>
<a class='btn btn-outline-dark btn-square' href='beli.php?id=<?php echo $i ?>'><i class='fa fa-shopping-cart'></i></a>
<a class='btn btn-outline-dark btn-square' href='detail.php?idp=<?php echo $i ?>'><i class='fa fa-search'></i></a>
</div>
</div>
<div class='text-center py-4'>
<a class='h6 text-decoration-none text-truncate' href=''>
<?= $product->getName() ?>
</a>
<div class='d-flex align-items-center justify-content-center mt-2'>
<h5>Rp.
<?= number_format($product->getPrice(), 0, ',', '.') ?>
</h5>
</div>
</div>
</div>
</div>
<?php endfor; ?>
</div>
</div>
<div class="container text-center">
<p class="mt-4"><a href='shop.php' class="btn btn-primary">Produk Lainnya</a></p>
</div>
</div>
</div>
<!-- Products End -->
<?php
include ('footer.php');
$footer = new footer();
$footer->render();
?>