-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelem_categ.php.bak
103 lines (85 loc) · 2.75 KB
/
elem_categ.php.bak
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
<?php
include("database.php");
include("front_head.php");
include("front_menu.php");
?>
<div id="hero_shoe" >
<h4>Collezione Moda 2022</h4>
<h2>I dettagli che fanno la differenza</h2>
<h1>Il pantalone giusto, per un'estate perfetta!</h1>
<p>Risparmia di più con i coupons, fino al 70% di sconto!</p>
<button>Acquista ora</button>
</div>
<div id="shoeHead" >
<span class="brid">
<a href='/shop/front_index.php'>Home</a> / <b><a href="elem_categ.php?id=<?php echo $_GET['id_cat'];?>
&tipo=<?php echo $_GET['tipo'];?>"><?php echo $_GET['tipo'];?></a></b>
</span>
<i><h1><?php echo $_GET['tipo'];?></h1></i>
<div class="filters">
<form id="searchFilter" action="elem_categ.php?id_cat=<?php echo $_GET['id_cat'];?>&tipo=<?php echo $_GET['tipo'];?>" method="POST">
<div class="distrSel">
<input class="shoeSearch" name="cerca" type="text" placeholder="Cerca">
<button class="shoeCerca" type="submit">
<i class="uil uil-search-alt"></i>
</button>
</div>
</form>
</div>
</div>
<?php
$id_categ = $_GET['id_cat'];
if(!isset($_POST['cerca'])) {
$cerca = "";
}else{
$cerca = $_POST['cerca'];
}
if($cerca ) {
$query = "SELECT id FROM categorie WHERE id_padre = $id_categ";
$result = mysqli_query($con, $query);
$array = [];
while ($r = mysqli_fetch_assoc($result)) {
$array[] = $r['id'];
}
$array = implode(',', $array);
$query = "SELECT * FROM articoli INNER JOIN marca ON articoli.id_marca = marca.id_mar WHERE (id_categoria = '$id_categ' OR id_categoria IN
($array)) AND (nome LIKE '%".$cerca."%' OR nome_marca LIKE '%".$cerca."%')";
$result = mysqli_query($con, $query);
}else{
$query = "SELECT id FROM categorie WHERE id_padre = $id_categ";
$result = mysqli_query($con, $query);
$array = [];
while ($r = mysqli_fetch_assoc($result)) {
$array[] = $r['id'];
}
$array = implode(',', $array);
$query = "SELECT * FROM articoli INNER JOIN marca ON articoli.id_marca = marca.id_mar WHERE id_categoria = '$id_categ' OR id_categoria IN
($array);";
$result = mysqli_query($con, $query);
}
if (!$result) {
echo 'Could not run query: ' . mysqli_error($con);
exit;
}
?>
<section id="feature" class="sectionP1">
<?php
if($result->num_rows > 0) {
while($row = $result->fetch_assoc()){
?>
<div class="imgShoeContainer">
<img src="/shop/admin/<?php echo $row['immagine']; ?>">
<h4><?php echo $row['nome']; ?></h4>
<h5><?php echo $row['nome_marca']; ?></h5>
<div class="shoePrice">
<b><?php echo $row['prezzo']; ?> €</b>
</div>
</div>
<?php }
}
else{
echo "Errore: non ci sono elementi con questo nome! " . $con->error;
}
?>
</section>
<?php include("front_footer.php"); ?>