///////////////////////////////////////////////////////////////////////////////// /* PAGE fonctions-panier.php */ <code class="php_keyword1">functioncreationPanier()
{
$
ret
=
false
;
if(isset(
$
_SESSION
[
'
panier
'
]))
$
ret
=
true
;
else
{
$
_SESSION
[
'
panier
'
]
=
array()
;
$
_SESSION
[
'
panier
'
]
[
'
libelleProduit
'
]
=
array()
;
$
_SESSION
[
'
panier
'
]
[
'
qteProduit
'
]
=
array()
;
$
_SESSION
[
'
panier
'
]
[
'
prixProduit
'
]
=
array()
;
$
ret
=
true
;
}
return
$
ret
;
}</code>
<code class="php_keyword1">functionajouterArticle(
$
libelleProduit
,
$
qteProduit
,
$
prixProduit)
{
if(creationPanier())
{
$
positionProduit
=array_search(
$
libelleProduit
,
$
_SESSION
[
'
panier
'
]
[
'
libelleProduit
'
])
;
if(
$
positionProduit
!
=
=
false)
{
$
_SESSION
[
'
panier
'
]
[
'
qteProduit
'
]
[
$
positionProduit
]
+
=
$
qteProduit
;
}
else
{
$
_SESSION
[
'
panier
'
]
[
'
libelleProduit
'
]
,
$
libelleProduit)
;
$
_SESSION
[
'
panier
'
]
[
'
qteProduit
'
]
,
$
qteProduit)
;
$
_SESSION
[
'
panier
'
]
[
'
prixProduit
'
]
,
$
prixProduit)
;
}
}
else
"
Un
problème
est
survenu
veuillez
contacter
l
'
administrateur
du
site
.
"
;
}
/* PAGE commande.php */
et ensuite, j'ajoute de cette manière : if (isset($_POST['libelle']) && isset($_POST['qte']) && isset($_POST['prix'])) { $libelleProduit=intval($_POST['libelle']); $qteProduit=intval($_POST['qte']); $prixProduit=floatval($_POST['prix']); ajouterArticle($libelleProduit,$qteProduit,$prixProduit); } $req=mysql_query("SELECT * FROM commande"); while ($res=mysql_fetch_array($req)) { $id=$res['id']; $txt=$res['texte']; $px=$res['prix']; echo $txt." - ".$px." <form action="" method="post"> </form> "; } ////////////////////////////////////////////////////////////////////////////////////
/* PAGE index.php */
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question<form action="" method="post"> </form>