-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
154 lines (121 loc) · 4.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
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
<?php
// Inicia uma sessão.
session_start();
// Cria conexão com o banco.
include("config.php");
// Chama função de conexão do arquivo 'config.php' acima.
$con=cnt();
// Chama função que direciona para a página restrita se já estiver logado (com uma SESSION aberta).
//$stay=in();
if(!empty($_SESSION['carrinho'])):
foreach($_SESSION['carrinho'] as $id => $qtd):
$prods = $con->prepare("SELECT * FROM produtos WHERE id=$id");
$prods->execute();
$prod = $prods->fetch(PDO::FETCH_ASSOC);
$name = $prod['name'];
$price = $prod['price'];
$sub = $prod['price'] * $qtd;
$total += $prod['price'] * $qtd;
endforeach;
else:
endif;
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=1300px,initial-scale=-3">
<title>Loja Exemplo</title>
<link rel="stylesheet" href="css/body.css"/>
<link href="//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<!-- jQuery library (served from Google) -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<!-- bxSlider Javascript file -->
<script src="js/jquery.bxslider.min.js"></script>
<!-- bxSlider CSS file -->
<link rel="stylesheet" href="css/jquery.bxslider.css"/>
<script type="text/jscript">
$(document).ready(function(){
$('.bxslider').bxSlider({
auto: true,
captions: true,
adaptiveHeight: true,
autoControls: true
});
});
</script>
</head>
<body>
<header>
<?php include("header.php"); ?>
</header>
<section>
<ul class="bxslider">
<?php
$banners = $con->prepare("SELECT * FROM banners ORDER BY id DESC");
$banners->execute();
while($banner = $banners->fetch(PDO::FETCH_ASSOC)):
?>
<a href="<?php echo $url; ?>/<?php echo $banner["catg"]; ?>"><li style="height:350px;background:#1E90FF url(img/banners/<?php echo $banner["img"]; ?>) 50% 50% no-repeat;background-size:cover;"></li></a>
<?php
endwhile;
?>
</ul>
<div class="container">
<ul id="menu_subcatg">
<?php
$categorias = $con->prepare("SELECT * FROM categorias ORDER BY name ASC");
$categorias->execute();
while($catgf = $categorias->fetch(PDO::FETCH_ASSOC)):
echo'<li><a href="'.$url.'/'.$catgf["catg"].'" style="color:#1E90FF;">'.$catgf["name"].'</a></li>';
$catgf = $catgf["catg"];
if(!empty($catgf)):
$subcategorias = $con->prepare("SELECT * FROM subcategorias WHERE catg='$catgf' ORDER BY subcatg ASC");
$subcategorias->execute();
while($subcatgf = $subcategorias->fetch(PDO::FETCH_ASSOC)):
echo'<li><a href="'.$url.'/'.$subcatgf["catg"].'/'.$subcatgf["subcatg"].'">'.$subcatgf["name"].'</a></li>';
endwhile;
endif;
endwhile;
?>
</ul>
<div id="produtos">
<?php
$prods = $con->prepare("SELECT * FROM produtos ORDER BY ordh DESC LIMIT 12");
$prods->execute();
while($prod = $prods->fetch(PDO::FETCH_ASSOC)):
?>
<div id="prod">
<a href="<?php echo $prod["catg"].'/'.$prod["subcatg"].'/'.$prod["id"]; ?>"><figure style="background:#fff url(img/products/<?php echo''.$prod["photo"].''; ?>) top center no-repeat;background-size:100% auto;"></figure></a>
<h3><?php echo $prod["name"]; ?></h3>
<!--<a href="<?php echo $prod["catg"].'/'.$prod["subcatg"].'/'.$prod["id"]; ?>"><span><?php echo''.$prod["catg"].''; ?></span></a>-->
<h3>R$ <?php echo str_replace('.',',',''.$prod["price"].''); ?></h3>
<?php
$price = ''.$prod["price"].'';
$parc = ''.$prod["parc"].'';
$parcel = $price / $parc;
if($parc==1):
echo'<span>no boleto bancário</span>';
else:
echo'<span>'.$prod["parc"].'x de R$ '.number_format($parcel, 2, ',','.').' no cartão de crédito</span>';
endif;
?>
<form id="buy" action="<?php echo $prod["catg"].'/'.$prod["subcatg"].'/'.$prod["id"]; ?>" method="POST">
<input type="submit" value="MAIS DETALHES" id="buy"/>
</form>
</div>
<?php
endwhile;
?>
</div>
<figure id="banners">
</figure>
</div>
</section>
<footer>
<div class="container">
<?php include("footer.php"); ?>
</div>
</footer>
</body>
</html>