<?php
include("session.php");
require"classes/productManager.php";
$productManager=new productManager();
require"classes/fonction-panier.php";
$erreur = false;
$action = (isset($_POST['action'])? $_POST['action']: (isset($_GET['action'])? $_GET['action']:null )) ;
if($action !== null)
{
if(!in_array($action,array('ajout', 'suppression', 'refresh')))
$erreur=true;
//récuperation des variables en POST ou GET
$l = (isset($_POST['l'])? $_POST['l']: (isset($_GET['l'])? $_GET['l']:null )) ;
$p = (isset($_POST['p'])? $_POST['p']: (isset($_GET['p'])? $_GET['p']:null )) ;
$q = (isset($_POST['q'])? $_POST['q']: (isset($_GET['q'])? $_GET['q']:null )) ;
//Suppression des espaces verticaux
$l = preg_replace('#\v#', '',$l);
//On verifie que $p soit un float
$p = floatval($p);
//On traite $q qui peut etre un entier simple ou un tableau d'entier
if (is_array($q)){
$QteArticle = array();
$i=0;
foreach ($q as $contenu){
$QteArticle[$i++] = intval($contenu);
}
}
else
$q = intval($q);
}
if (!$erreur){
switch($action){
Case "ajout":
ajouterArticle($l,$q,$p);
break;
Case "suppression":
supprimerArticle($l);
break;
Case "refresh" :
for ($i = 0 ; $i < count($QteArticle) ; $i++)
{
modifierQTeArticle($_SESSION['panier']['libelleProduit'][$i],round($QteArticle[$i]));
}
break;
Default:
break;
}
}
<form method="post" action="panier.php">
<div align="right" class="greybutton"><a href="client.php">continuer votre achat</a></div><br /><br /><br />
<table id="affpanier">
<tr>
<td colspan="4">Votre panier</td>
</tr>
<tr>
<td>Libellé</td>
<td>Quantité</td>
<td>Prix Unitaire</td>
<td>Action</td>
</tr>
<?php
if (creationPanier())
{
$nbArticles=count($_SESSION['panier']['libelleProduit']);
if ($nbArticles <= 0)
echo "<div><tr><td>Votre panier est vide </ td></tr></div>";
else
{
for ($i=0 ;$i < $nbArticles ; $i++)
{
echo "<tr>";
echo "<td><img src=\"images\yep.png\" width=\"35\" height=\"26\">".htmlspecialchars($_SESSION['panier']['libelleProduit'][$i])."</ td>";
echo "<td><input type=\"text\" size=\"4\" name=\"q[]\" value=\"".htmlspecialchars($_SESSION['panier']['qteProduit'][$i])."\"/></td>";
echo "<td>".htmlspecialchars($_SESSION['panier']['prixProduit'][$i])."</td>";
echo "<td><a href=\"".htmlspecialchars("panier.php?action=suppression&l=".rawurlencode($_SESSION['panier']['libelleProduit'][$i]))."\"><img src=\"images\corbeille.png\" width=\"35\" height=\"26\"></a></td>";
echo "</tr>";
}
echo "<tr><td colspan=\"2\"> </td>";
echo "<td colspan=\"2\">";
echo "<div id=\"totaltext\"> Total : ".MontantGlobal()."</div>";
echo "</td></tr>";
echo "<tr><td colspan=\"4\">";
echo "<input class=\"orangebutton\" type=\"submit\" value=\"Recalculer\"/>";
echo "<input type=\"hidden\" name=\"action\" value=\"refresh\"/>";
echo "</td></tr>";
}
}
?>
</table>
mai je demande mnt comment je pourrais inserer ce panier dans la table ligne commande , j'ai vu le mm sujet dans le forum mais je n'ai pas reussi a bien comprendre comment ils ont reglé probleme mais voici mon code pour faire l'insertion
<?php
include("session.php");
include("connexion.php");
require"classes/fonction-panier.php";
if (creationPanier()){
$panier=$_SESSION['panier'];
$lignes = explode('#', $_SESSION['panier']);
foreach($lignes as $line){
$mot = explode(';',$line);
$sql = 'INSERT INTO Contient(`idArticle`, `idCmd`, `QteArt`) VALUES (\''.$mot[0].'\', \''.$mot[1].'\', \''.$mot[2].'\');';
$result = mysql_query($sql) or die("erreur!!");
mysql_close();
}
echo MontantGlobal();
}
?>
ca me donné ce genre d'erreur et je sais pas regler ce probleme alors si quelqu'un pourrais m'aider ca serai sympaWarning: explode() expects parameter 2 to be string, array given in C:\Program Files (x86)\EasyPHP-12.0\www\evatis - Copie\commander.php on line 8
Warning: Invalid argument supplied for foreach() in C:\Program Files (x86)\EasyPHP-12.0\www\evatis - Copie\commander.php on line 9