forked from Stanley-Jovel/CandyShop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
39 lines (38 loc) · 1.66 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
<?php include 'include/header.php'; ?>
<section class="col-md-6 col-lg-6 col-sm-12 col-xs-12" id="body">
<?php
$count = 0;
$categorias = isset($_GET["idcategoria"])?getCategorias($_GET["idcategoria"]):getCategorias();
echo count($categorias)>0?"":'<script>window.location.href="' . $base_url . '";</script>';
foreach ($categorias as $key => $categoria) {
$productos = isset($_GET["nombre"])?getProductoPorCategoria($categoria['idcategoria'],$_GET["nombre"]):getProductoPorCategoria($categoria['idcategoria']);
if (count($productos)>0) {
echo "<h3>".$categoria['nombre']."</h3><hr/>";
echo "<div class='row'>";
}
$count += count($productos);
foreach ($productos as $key => $producto) {
?>
<!-- <div class="col-md-2 col-lg-2 col-sm-3 col-xs-12 producto-container"> -->
<div class="col-md-6 col-lg-3 col-sm-6 col-xs-12 producto-container">
<div class="producto">
<span class='producto-precio'>$<?=$producto['precio'];?></span>
<a href="./detalles.php?id=<?=$producto['id']; ?>">
<img class="fixed-height" src="./productos/<?=$producto['imagen'];?>">
<h2 class='producto-nombre'><?=$producto['nombre'];?></h2>
</a>
<div class="producto-detalles">
<!-- Agregando comentareo -->
<!-- <a class='btn btn-success' href="./detalles.php?id=<?=$producto['id']; ?>">Detalles</a> -->
<a class='btn btn-primary' href="./carritodecompras.php?id=<?=$producto['id']; ?>">Agregar al carrito</a>
</div>
</div>
</div>
<?php
}
echo "</div>";
}
echo $count<=0?"<div class='alert alert-warning' role='alert'>No hay productos a mostrar</div>":"";
?>
</section>
<?php include 'include/footer.php'; ?>