Bonsoir,

Après avoir créé mon panier, je voudrais récupérer les données pour générer un fichier en guise de facture mais malheureusement mes données sont sous forme de tableau.En effet, ça m'indique que mes variables qui sont dans le fwrite sont des tableaux. J'aurais fortement besoin de votre aide; s'il vous plait.

Merci d'avance.
Code : 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
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
 
<?php
  if (creationPanier())
  {
     $nbArticles=count($_SESSION['panier']['libelleProduit']);
     if ($nbArticles <= 0)
     echo "Votre panier est vide";
     else
     {
        for ($i=0 ;$i < $nbArticles ; $i++)
        {
            try
           {
 
              $bdd = new PDO('mysql:host=localhost;dbname=projet;charset=utf8', 'root', '');
              $bdd->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); // Les noms de champ seront en minuscule
              $bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //Les erreurs lanceront des excetions
 
          }
 
          catch(Exception $e)
          {
 
              die("Une erreur est survenue");
 
           }
           //Récupération de la TVA
           $select = $bdd->query("SELECT TVA FROM produit");
           $data = $select->fetch(PDO::FETCH_OBJ);
           $_SESSION['panier']['tva'] = $data->tva;
          ?>
           <tr>
 
            <td></br><?php echo htmlspecialchars($_SESSION['panier']['libelleProduit'][$i]);?></td>
            <td></br><input type="number" size="4" name="q[]" value="<?php echo htmlspecialchars($_SESSION['panier']['qteProduit'][$i]);?>"/></td>
            <td></br><?php echo htmlspecialchars($_SESSION['panier']['prixProduit'][$i]);?></td>
            <td></br><?php echo htmlspecialchars($_SESSION['panier']['tva'].'%');?></td>
            <td></br><a href="panier.php?action=suppression&amp; l=<?php echo rawurlencode($_SESSION['panier']['libelleProduit'][$i]);?>" >supprimer</a></td>
 
           </tr>
        <?php
        }
        ?>
 
        <tr>
        <td colspan="5">
         <p>Total : <?php echo montantGlobal()."€";?></p>
         <p>Total avec tva : <?php echo montantGlobalTva()."€";?></p>
         <p>Frais de port : <?php echo CalculFraisPort()."€";?></p>
         <p> <a href=""><input type="submit" name="payerCommande" value="payer la commande"/></a></p>
         </td>
       </tr>
 
        <tr><td colspan="5">
        <input type="submit" value="Rafraichir" id="rafraichir"/>
        <input type="hidden" name="action" value="refresh"/>
         <a href="?deletepanier=true">supprimer le panier </a>
         </td></tr>
 
        <?php
        $montantGlobal = montantGlobal();
        $montantGlobalTva = montantGlobalTva();
        $libelle = $_SESSION['panier']['libelleProduit'];
        $qtep = $_SESSION['panier']['qteProduit'];
        $prixunit = $_SESSION['panier']['prixProduit'];
        if(isset($_POST['payerCommande'])){
 
           $fichier = fopen("commande1.txt", "w");
           fwrite($fichier, "Nom du produit: $libelle");
           fwrite($fichier, "Prix Unitaire du produit: $prixunit");
           fwrite($fichier, "Quantité du produit: $qtep");
           fwrite($fichier, "Montant global  du produit sans le TVA: $montantGlobal");
           fwrite($fichier, "Montant global  du produit sans le TVA: $montantGlobalTva");
           fwrite($fichier, "Nom du produit: $libelle");
        }
 
     }
  }
  ?>
 </table>