bonsoir à tous
je suis en train d'essayer de détruire un article d'une variable de session qui est sous forme d'un tableau qui contient les articles ajouter au panier,le probléme j'arrive pas détruire les articles de ma page qui contiens la liste des produits
mon tableau contient l'information suivante:
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
<?php
$carro[$id]=array('id'=>$r["id"],'title'=>$r['title'],'price'=>$r['price'],'cantidad'=>$cantidad);
$_SESSION['carro']=$carro;
cette information que je passe au fichier suivant see_cart.php:
see_cart.php
je vous montre le liens qui fait appelle a détruire des articles du pannier
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
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
<?php
  session_start(); 
  if(isset($_SESSION['carro'])) 
     $carro=$_SESSION['carro']; 
   else 
     $carro=false; 
 
   $images=1; 
   echo "<table border = 0 width = 100% cellspacing = 0> 
        <form action = show_carte.php method = post> 
        <tr><th colspan = ". (1+$images) ." bgcolor=\"#cccccc\">Item</th> 
        <th bgcolor=\"#cccccc\">Price</th><th bgcolor=\"#cccccc\">Quantity</th> 
        <th bgcolor=\"#cccccc\"><th><th>Borrar</th></th></tr>"; 
   $contador=0; 
   $suma=0; 
  foreach($carro as $k => $v) 
   { 
       $subto=$v['cantidad']*$v['price']; 
       $suma=$suma+$subto; 
       $contador++; 
       echo "<td align =\" left\">"; 
       echo "<td>".$v['title']."</td>"; 
       echo "<td align ='center'<b>".$v['price']."€</td></b>"; 
       echo "<td width='43' align='center'><b>".$v['cantidad']."</b></td>"; 
       echo "<td width='136' align='center'>"; 
       echo "<td width='100' align='center'></td>";?> 
       </span> 
       <!--ici je passe el id du produit que j'ai envie d'enlever de mon panier  
        fichero borracar.php--> 
       </div><br><td align="center"><a href="borracar.php?id=<?php echo $v['id']; ?>"><img src="carro.jpg" width="20" height="20" border="0"></a></td> 
       </tr></form> 
   <?php }   ?> 
    </table> 
 
    <br> 
    <br> 
    <div align="center"><span class="prod">Total de Artículos: <?php echo '<b>'.count($carro).'</b>'; 
    echo "<tr>"; 
    echo "<br>"; 
    echo "</tr>"; 
    ?> 
    </span> 
    </div><br> 
    <div align="center"><span class="prod"><b>Total: $</b><?php echo number_format($suma,2); 
    echo "</span>"; 
    echo "</div><br>";?> 
  </table><br> 
<br>

dans le fichier borrarcar.php:
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
<?php
session_start(); 
//j'ai essayé avec unset($_SESSION[$id]); mais ca marche pas
unset($_SESSION[$_GET['id']]);
//var_dump($carrro);  
header("Location:show_carte.php?".$carro);
j'attends votre suggestion y votre acclaration.
merci d'avance.