Salve a tutti!!
Ho bisogno di fare un comparatore prezzi che, quando un utente effettua una ricerca non trova:
prodotto-> 1 negozio ma prodotto-> n negozi.
Esempio:
fx-6350 -> store A ----> 90€
fx-6350 -> store B ----> 80€
fx-6350 -> store C ----> 110€
i7 -> store B ----> 290€
i7 -> store C ----> 320€
invece vorrei qualcosa del genere:
+fx-6350
| -------> store A ----> 90€
| -------> store B ----> 80€
| -------> store C ----> 110€
+i7
| -----> B Store ----> 290€
| -----> C Store ----> 320€
Insomma per ogni prodotto ragruppare i negozi che hanno quel prodotto. Ho provato con 2 cicle while e 2 query ma niente
...Sicuramente esiste un modo diverso per farlo.
Per darvi una idea vi posto la parte saliente del codice:
Codice PHP:
<?php
$connessione = new mysqli(localhost, root, password, comparator2);
if ($connessione->connect_errno) {
echo "Connessione fallita: ". $connessione->mysqli_connect_error . ".";
exit();
}
$sql = "select * from comparator2.prodotti,comparator2.descrizione_prodotti
where idprodotti = descrizione_prodotti.prodotti_idprodotti
and descrizione_prodotti.lingue_idlingue = 1
and match (sku, nome_prodotto) against ('*16n*' IN BOOLEAN MODE)
or match (descrizione_prodotti.descrizione_prodotto) against ('*16n*' IN BOOLEAN MODE)";
$result = mysqli_query($connessione, $sql);
$sql2 ="select * from comparator2.prodotti, comparator2.negozi_prezzi, comparator2.negozi, comparator2.descrizione_prodotti
where prodotti.idprodotti = negozi_prezzi.prodotti_idprodotti
and negozi_prezzi.negozi_idnegozi = negozi.idnegozi
and idprodotti = descrizione_prodotti.prodotti_idprodotti
and descrizione_prodotti.lingue_idlingue = 1
and match (sku, nome_prodotto) against ('*16n*' IN BOOLEAN MODE)
or match (descrizione_prodotti.descrizione_prodotto) against ('*16n*' IN BOOLEAN MODE)";
$result2 = mysqli_query($connessione, $sql2);
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
echo '<img src="';
$img_prodotti_nn = $row["img_prodotti"];
$img_prodotti = json_decode($img_prodotti_nn,true);
foreach($img_prodotti as $ima) {echo $ima[small];}
echo '" alt="';
echo $row['nome_prodotto'].'" /><br>';
echo $row['negozi_prezzi_prezzi'];
echo $row['nome_prodotto'];
while($row2 = mysqli_fetch_assoc($result2)) {
echo '<img src="' . $row2['logo_negozi'].'" alt="'.$row2['nome_negozi'].'" width="30px"><br>';
echo 'nome :'.$row2['nome_negozi'].'<br>';
echo 'prezzo: '.$row2['negozi_prezzi_prezzi'].'<br>';
echo 'descrizione: '.$row2['descrizione_prodotto'].'<br>';
echo 'nome: '. $row2['nome_prodotto'].'<br>';
echo '<br><br>';
}
}}
?>
16n è come una simulazione di ricerca, invece di mettere le variabili ecc
Grazie!