bonjour
j'ai récupéré un morceau de code pour enregistrer les produits consultés mais je n'arrive pas à corriger 2 bugs:
1. pas de test si le produit est déjà dans le tableau
2. affichage de 8 images dont 7 vides si le tableau ne contient qu'une ligne
est ce qu'une bonne âme peut m'aider?
partie affichage:Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 if (isset($_SESSION['ProdVu'])) { $ProdVu = ($_SESSION['ProdVu']); } else { $ProdVu = array(array()); } // ici bug1 manque test si article deja present array_unshift($ProdVu, array("ID" => $resultat['ID'], "IMG" => $resultat[$image])); if (sizeof($ProdVu) > 8) { array(array_pop($ProdVu)); } //limite a 8 $_SESSION['ProdVu'] = $ProdVu; $NbProdVu = sizeof($ProdVu);
Code:
1
2
3
4
5
6
7
8
9
10 <? for ($row = 0; $row < 8; $row++) //ici bug 2 { echo "<td><a href='lien.php?ID=".$ProdVu[$row]['ID']."'> <img src='/".$ProdVu[$row]['IMG']."' border='0' width='50' /> </a> </td>"; } ?>