Problème de l'afffichage
samiapirou
Messages postés
143
Statut
Membre
-
Exileur Messages postés 1621 Statut Membre -
Exileur Messages postés 1621 Statut Membre -
Salut,j'ai fait un panier pour les pièce,le pb c'est que si le premier client qui rentre et passe la commande normale lors de la l'affichage de sa commande il affiche le nom le prenom la quantité le prix et le nom du produit commandé mais si un autre client qui accede et passe la commande il lui affiche juste le nom et le prenom mais la quantité le prix et le nom du produit il affiche dans la commande du premiers clien.et aussi sans la commande du premier client qui accede s'il fait plus d'une commande il lui affiche ceci voila s qu'il affiche num commande:1
nom:aze
prenom:loi
quantite*prix|nom produit
4*150------miroir
total:600
et la deuxième commande qui'il passe il affiche seulement le nom,prenom,total et la quantite le prix et le nom du produit il affiche dans la première commande
num commande:2
nom:aze
prenom:loi
total:800
donc la première commande devienne comme suit
nom:aze
prenom:loi
quantite*prix|nom produit
4*150------miroir
6*250--------porte
total:600
et pour le deuxième client qui accede il afffiche juste ca par exemple:
num commande:2
nom:aze
prenom:loi
total:800
donc voila le panier_fct.php::::
<?php
include('connexion.php');
function creationPanier(){
if (!isset($_SESSION['panier'])){
$_SESSION['panier']=array();
$_SESSION['panier']['ident'] = array();
$_SESSION['panier']['refProduit'] = array();
$_SESSION['panier']['qteProduit'] = array();
$_SESSION['panier']['prixProduit'] = array();
$_SESSION['panier']['verrou'] = false;
}
return true;
}
function ajouterArticle($ident,$refart,$qteProduit,$prixProduit){
//Si le panier existe
if (creationPanier() && !isVerrouille())
{
//Si le produit existe déjà on ajoute seulement la quantité
$positionProduit = array_search($refart, $_SESSION['panier']['refProduit']);
if ($positionProduit !== false)
{
$_SESSION['panier']['qteProduit'][$positionProduit] += $qteProduit ;
}
else
{
//Sinon on ajoute le produit
array_push( $_SESSION['panier']['ident'],$ident);
array_push( $_SESSION['panier']['refProduit'],$refart);
array_push( $_SESSION['panier']['qteProduit'],$qteProduit);
array_push( $_SESSION['panier']['prixProduit'],$prixProduit);
}
}
else
echo "Un problème est survenu veuillez contacter l'administrateur du site.";
}
function modifierQTeArticle($refart,$qteProduit){
//Si le panier éxiste
if (creationPanier() && !isVerrouille())
{
//Si la quantité est positive on modifie sinon on supprime l'article
if ($qteProduit > 0)
{
//Recharche du produit dans le panier
$positionProduit = array_search($refart, $_SESSION['panier']['refProduit']);
if ($positionProduit !== false)
{
$_SESSION['panier']['qteProduit'][$positionProduit] = $qteProduit ;
}
}
else
supprimerArticle($refart);
}
else
echo "Un problème est survenu veuillez contacter l'administrateur du site.";
}
function supprimerArticle($refart){
//Si le panier existe
if (creationPanier() && !isVerrouille())
{
//Nous allons passer par un panier temporaire
$tmp=array();
$tmp['ident'] = array();
$tmp['refProduit'] = array();
$tmp['qteProduit'] = array();
$tmp['prixProduit'] = array();
$tmp['verrou'] = $_SESSION['panier']['verrou'];
for($i = 0; $i < count($_SESSION['panier']['refProduit']); $i++)
{
if ($_SESSION['panier']['refProduit'][$i] !== $refart)
{
array_push( $tmp['ident'],$_SESSION['panier']['ident'][$i]);
array_push( $tmp['refProduit'],$_SESSION['panier']['refProduit'][$i]);
array_push( $tmp['qteProduit'],$_SESSION['panier']['qteProduit'][$i]);
array_push( $tmp['prixProduit'],$_SESSION['panier']['prixProduit'][$i]);
}
}
//On remplace le panier en session par notre panier temporaire à jour
$_SESSION['panier'] = $tmp;
//On efface notre panier temporaire
unset($tmp);
}
else
echo "Un problème est survenu veuillez contacter l'administrateur du site.";
}
function MontantGlobal(){
$total=0;
for($i = 0; $i < count($_SESSION['panier']['refProduit']); $i++)
{
$total += $_SESSION['panier']['qteProduit'][$i] * $_SESSION['panier']['prixProduit'][$i];
}
return $total;
}
function supprimePanier(){
unset($_SESSION['panier']);
}
function isVerrouille(){
if (isset($_SESSION['panier']) && $_SESSION['panier']['verrou'])
return true;
else
return false;
}
function compterArticles()
{
if (isset($_SESSION['panier']))
return count($_SESSION['panier']['refProduit']);
else
return 0;
}
function validercommande($ident)
{
$connection = mysql_connect("localhost","root","");
if ( ! $connection )
die ("connection impossible");
//On sélectionne la BDD
$mabasededonnee="bdd";
mysql_select_db($mabasededonnee) or die ("pas de connection");
if (creationPanier())
{
isVerrouille();
$montant=MontantGlobal();
$client=$_SESSION['log_cli'];
$req ="INSERT INTO commande (num_com,login_client,montant_com,valid_cmd,date_com) VALUES ('','$client','$montant','0',curdate())";
mysql_query($req,$connection);
$az=mysql_query("select * from 'commande'");
$k=0;
while ($k<mysql_num_rows($az))
{
$zz=mysql_fetch_row($az);
$num_comm=$zz[0];
$k=$k+1;
}
for($i = 0; $i < count($_SESSION['panier']['refProduit']); $i++)
{
$num_produit= $_SESSION['panier']['ident'][$i];
$qtt_produit= $_SESSION['panier']['qteProduit'][$i];
$requete ="INSERT INTO commande_piece (id_piece,num_piece,num_commande,qtt) VALUES ('','$num_produit','$num_comm','$qtt_produit')";
mysql_query($requete,$connection);
}
mysql_close($connection);
supprimePanier();
header("Location: commande_cli.php") ;
}
}
?>
la commande_cli.php ::::::voici le code
<?php
//connexion a la base
$connection = mysql_connect("localhost","root","");
if ( ! $connection )
die ("connection impossible");
//On sélectionne la BDD
$mabasededonnee="bdd";
mysql_select_db($mabasededonnee) or die ("pas de connection");
$e=$_SESSION['log_cli'];
$req=mysql_query("select * from 'commande' where ((login_client='$e') && (valid_cmd='0'))")or die (mysql_error());
$i=0;
while ($i<mysql_num_rows($req))
{
$ligne=mysql_fetch_row($req);
echo"
<table class='affich' align='center' cellspacing='1' >
<tr>
<td width=70%>
<b>Numero de commande :</b>".$ligne[0]."";
$r=mysql_query("SELECT * FROM client WHERE login_client='$ligne[1]'")or die (mysql_error());
$li=mysql_fetch_row($r);
echo"
<br><b>Nom client : </b>".$li[1]."
<br><b>Prénom client : </b>".$li[2]."<br>
<br><b>Quantité X Prix U</b> | <b>Nom Produit</b> <br><br>
";
$az=mysql_query("select * from 'commande_piece' where num_commande='$ligne[0]'")or die (mysql_error());
$k=0;
while ($k<mysql_num_rows($az))
{
$zz=mysql_fetch_row($az);
$produit=mysql_query("select * from 'piece' where num_piece='$zz[1]'")or die (mysql_error());
$pro=mysql_fetch_row($produit);
echo "(".$zz[3]." X ".$pro[5]." DA) -------- ".$pro[2]."<br>";
$k=$k+1;
};echo"
<br><b>Montant Total à payer : </b>".$ligne[2]." DA
</td>
<td align=center>
<div id='aj_panier'><a href=\"#\" onClick=\"confirme('".$ligne[0]."')\" >Annuler Commande</a>
</div>";
echo"</td></tr>
</table>";
echo"";
echo"<HR>";
$i=$i+1;
}
$req=mysql_query("select * from 'commande' where ((login_client='$e') && (valid_cmd='1'))");
$i=0;
while ($i<mysql_num_rows($req))
{
$ligne=mysql_fetch_row($req);
echo"
<table class='affich' align='center' cellspacing='1' >
<tr>
<td width=70%>
<b>Numéro commande :</b> ".$ligne[0]."
";$r=mysql_query("select * from 'client' where login_client='$ligne[1]'");
$li=mysql_fetch_row($r);
echo"
<br><b>Nom client : </b>".$li[1]."
<br><b>Prénom client : </b>".$li[2]."<br>
<br><b>Quantité X Prix U</b> | <b>Nom Produit</b> <br><br>
";
$az=mysql_query("select * from 'commande_piece' where num_commande='$ligne[0]'")or die (mysql_error());
$k=0;
while ($k<mysql_num_rows($az))
{
$zz=mysql_fetch_row($az);
$produit=mysql_query("select * from 'piece' where num_piece='$zz[1]'")or die (mysql_error());
$pro=mysql_fetch_row($produit);
echo "(".$zz[3]." X ".$pro[5]." DA) -------->> ".$pro[2]."<br>";
$k=$k+1;
};echo"
<br><b>Montant Total à payer : </b>".$ligne[2]." DA
</td>
<td align=center>
<div id='commande_OK'><a><b>Commande Validée</b></a>
</div></td>
</tr>
</table>";
echo"";
echo"<HR>";
$i=$i+1;
}
$req=mysql_query("select * from 'commande' where ((login_client='$e') && (valid_cmd='-1'))")or die (mysql_error());
$i=0;
while ($i<mysql_num_rows($req))
{
$ligne=mysql_fetch_row($req);
echo"
<table class='affich' align='center' cellspacing='1' >
<tr>
<td width=70%>
<b>Numéro commande :</b> ".$ligne[0]."
";$r=mysql_query("select * from 'client' where login_client='$ligne[1]'")or die (mysql_error());
$li=mysql_fetch_row($r);
echo"
<br><b>Nom client : </b>".$li[1]."
<br><b>Prénom client : </b>".$li[2]."<br>
<br><b>Quantité X Prix U</b> | <b>Nom Produit</b> <br><br>
";
$az=mysql_query("select * from 'commande_piece' where num_commande='$ligne[1]'")or die (mysql_error());
$k=0;
while ($k<mysql_num_rows($az))
{
$zz=mysql_fetch_row($az);
$produit=mysql_query("select * from 'piece' where num_piece='$zz[1]'")or die (mysql_error());
$pro=mysql_fetch_row($produit);
echo "(".$zz[3]." X ".$pro[5]." DA) -------- ".$pro[2]."<br>";
$k=$k+1;
};echo"
<br><b>Montant Total à payer : </b>".$ligne[2]." DA
</td>
<td>
<div id='commande_Non'><a><b>Commande Rejetée<br>
Veuillez contacter le vendeur</b></a>
</div>
</td></tr>
</table>";
echo"";
echo"<HR>";
$i=$i+1;
}
mysql_free_result($req);
mysql_close($connection); //Puis on se déconnecte
?>
Svp aider moi c vraiment urgent
Merci
nom:aze
prenom:loi
quantite*prix|nom produit
4*150------miroir
total:600
et la deuxième commande qui'il passe il affiche seulement le nom,prenom,total et la quantite le prix et le nom du produit il affiche dans la première commande
num commande:2
nom:aze
prenom:loi
total:800
donc la première commande devienne comme suit
nom:aze
prenom:loi
quantite*prix|nom produit
4*150------miroir
6*250--------porte
total:600
et pour le deuxième client qui accede il afffiche juste ca par exemple:
num commande:2
nom:aze
prenom:loi
total:800
donc voila le panier_fct.php::::
<?php
include('connexion.php');
function creationPanier(){
if (!isset($_SESSION['panier'])){
$_SESSION['panier']=array();
$_SESSION['panier']['ident'] = array();
$_SESSION['panier']['refProduit'] = array();
$_SESSION['panier']['qteProduit'] = array();
$_SESSION['panier']['prixProduit'] = array();
$_SESSION['panier']['verrou'] = false;
}
return true;
}
function ajouterArticle($ident,$refart,$qteProduit,$prixProduit){
//Si le panier existe
if (creationPanier() && !isVerrouille())
{
//Si le produit existe déjà on ajoute seulement la quantité
$positionProduit = array_search($refart, $_SESSION['panier']['refProduit']);
if ($positionProduit !== false)
{
$_SESSION['panier']['qteProduit'][$positionProduit] += $qteProduit ;
}
else
{
//Sinon on ajoute le produit
array_push( $_SESSION['panier']['ident'],$ident);
array_push( $_SESSION['panier']['refProduit'],$refart);
array_push( $_SESSION['panier']['qteProduit'],$qteProduit);
array_push( $_SESSION['panier']['prixProduit'],$prixProduit);
}
}
else
echo "Un problème est survenu veuillez contacter l'administrateur du site.";
}
function modifierQTeArticle($refart,$qteProduit){
//Si le panier éxiste
if (creationPanier() && !isVerrouille())
{
//Si la quantité est positive on modifie sinon on supprime l'article
if ($qteProduit > 0)
{
//Recharche du produit dans le panier
$positionProduit = array_search($refart, $_SESSION['panier']['refProduit']);
if ($positionProduit !== false)
{
$_SESSION['panier']['qteProduit'][$positionProduit] = $qteProduit ;
}
}
else
supprimerArticle($refart);
}
else
echo "Un problème est survenu veuillez contacter l'administrateur du site.";
}
function supprimerArticle($refart){
//Si le panier existe
if (creationPanier() && !isVerrouille())
{
//Nous allons passer par un panier temporaire
$tmp=array();
$tmp['ident'] = array();
$tmp['refProduit'] = array();
$tmp['qteProduit'] = array();
$tmp['prixProduit'] = array();
$tmp['verrou'] = $_SESSION['panier']['verrou'];
for($i = 0; $i < count($_SESSION['panier']['refProduit']); $i++)
{
if ($_SESSION['panier']['refProduit'][$i] !== $refart)
{
array_push( $tmp['ident'],$_SESSION['panier']['ident'][$i]);
array_push( $tmp['refProduit'],$_SESSION['panier']['refProduit'][$i]);
array_push( $tmp['qteProduit'],$_SESSION['panier']['qteProduit'][$i]);
array_push( $tmp['prixProduit'],$_SESSION['panier']['prixProduit'][$i]);
}
}
//On remplace le panier en session par notre panier temporaire à jour
$_SESSION['panier'] = $tmp;
//On efface notre panier temporaire
unset($tmp);
}
else
echo "Un problème est survenu veuillez contacter l'administrateur du site.";
}
function MontantGlobal(){
$total=0;
for($i = 0; $i < count($_SESSION['panier']['refProduit']); $i++)
{
$total += $_SESSION['panier']['qteProduit'][$i] * $_SESSION['panier']['prixProduit'][$i];
}
return $total;
}
function supprimePanier(){
unset($_SESSION['panier']);
}
function isVerrouille(){
if (isset($_SESSION['panier']) && $_SESSION['panier']['verrou'])
return true;
else
return false;
}
function compterArticles()
{
if (isset($_SESSION['panier']))
return count($_SESSION['panier']['refProduit']);
else
return 0;
}
function validercommande($ident)
{
$connection = mysql_connect("localhost","root","");
if ( ! $connection )
die ("connection impossible");
//On sélectionne la BDD
$mabasededonnee="bdd";
mysql_select_db($mabasededonnee) or die ("pas de connection");
if (creationPanier())
{
isVerrouille();
$montant=MontantGlobal();
$client=$_SESSION['log_cli'];
$req ="INSERT INTO commande (num_com,login_client,montant_com,valid_cmd,date_com) VALUES ('','$client','$montant','0',curdate())";
mysql_query($req,$connection);
$az=mysql_query("select * from 'commande'");
$k=0;
while ($k<mysql_num_rows($az))
{
$zz=mysql_fetch_row($az);
$num_comm=$zz[0];
$k=$k+1;
}
for($i = 0; $i < count($_SESSION['panier']['refProduit']); $i++)
{
$num_produit= $_SESSION['panier']['ident'][$i];
$qtt_produit= $_SESSION['panier']['qteProduit'][$i];
$requete ="INSERT INTO commande_piece (id_piece,num_piece,num_commande,qtt) VALUES ('','$num_produit','$num_comm','$qtt_produit')";
mysql_query($requete,$connection);
}
mysql_close($connection);
supprimePanier();
header("Location: commande_cli.php") ;
}
}
?>
la commande_cli.php ::::::voici le code
<?php
//connexion a la base
$connection = mysql_connect("localhost","root","");
if ( ! $connection )
die ("connection impossible");
//On sélectionne la BDD
$mabasededonnee="bdd";
mysql_select_db($mabasededonnee) or die ("pas de connection");
$e=$_SESSION['log_cli'];
$req=mysql_query("select * from 'commande' where ((login_client='$e') && (valid_cmd='0'))")or die (mysql_error());
$i=0;
while ($i<mysql_num_rows($req))
{
$ligne=mysql_fetch_row($req);
echo"
<table class='affich' align='center' cellspacing='1' >
<tr>
<td width=70%>
<b>Numero de commande :</b>".$ligne[0]."";
$r=mysql_query("SELECT * FROM client WHERE login_client='$ligne[1]'")or die (mysql_error());
$li=mysql_fetch_row($r);
echo"
<br><b>Nom client : </b>".$li[1]."
<br><b>Prénom client : </b>".$li[2]."<br>
<br><b>Quantité X Prix U</b> | <b>Nom Produit</b> <br><br>
";
$az=mysql_query("select * from 'commande_piece' where num_commande='$ligne[0]'")or die (mysql_error());
$k=0;
while ($k<mysql_num_rows($az))
{
$zz=mysql_fetch_row($az);
$produit=mysql_query("select * from 'piece' where num_piece='$zz[1]'")or die (mysql_error());
$pro=mysql_fetch_row($produit);
echo "(".$zz[3]." X ".$pro[5]." DA) -------- ".$pro[2]."<br>";
$k=$k+1;
};echo"
<br><b>Montant Total à payer : </b>".$ligne[2]." DA
</td>
<td align=center>
<div id='aj_panier'><a href=\"#\" onClick=\"confirme('".$ligne[0]."')\" >Annuler Commande</a>
</div>";
echo"</td></tr>
</table>";
echo"";
echo"<HR>";
$i=$i+1;
}
$req=mysql_query("select * from 'commande' where ((login_client='$e') && (valid_cmd='1'))");
$i=0;
while ($i<mysql_num_rows($req))
{
$ligne=mysql_fetch_row($req);
echo"
<table class='affich' align='center' cellspacing='1' >
<tr>
<td width=70%>
<b>Numéro commande :</b> ".$ligne[0]."
";$r=mysql_query("select * from 'client' where login_client='$ligne[1]'");
$li=mysql_fetch_row($r);
echo"
<br><b>Nom client : </b>".$li[1]."
<br><b>Prénom client : </b>".$li[2]."<br>
<br><b>Quantité X Prix U</b> | <b>Nom Produit</b> <br><br>
";
$az=mysql_query("select * from 'commande_piece' where num_commande='$ligne[0]'")or die (mysql_error());
$k=0;
while ($k<mysql_num_rows($az))
{
$zz=mysql_fetch_row($az);
$produit=mysql_query("select * from 'piece' where num_piece='$zz[1]'")or die (mysql_error());
$pro=mysql_fetch_row($produit);
echo "(".$zz[3]." X ".$pro[5]." DA) -------->> ".$pro[2]."<br>";
$k=$k+1;
};echo"
<br><b>Montant Total à payer : </b>".$ligne[2]." DA
</td>
<td align=center>
<div id='commande_OK'><a><b>Commande Validée</b></a>
</div></td>
</tr>
</table>";
echo"";
echo"<HR>";
$i=$i+1;
}
$req=mysql_query("select * from 'commande' where ((login_client='$e') && (valid_cmd='-1'))")or die (mysql_error());
$i=0;
while ($i<mysql_num_rows($req))
{
$ligne=mysql_fetch_row($req);
echo"
<table class='affich' align='center' cellspacing='1' >
<tr>
<td width=70%>
<b>Numéro commande :</b> ".$ligne[0]."
";$r=mysql_query("select * from 'client' where login_client='$ligne[1]'")or die (mysql_error());
$li=mysql_fetch_row($r);
echo"
<br><b>Nom client : </b>".$li[1]."
<br><b>Prénom client : </b>".$li[2]."<br>
<br><b>Quantité X Prix U</b> | <b>Nom Produit</b> <br><br>
";
$az=mysql_query("select * from 'commande_piece' where num_commande='$ligne[1]'")or die (mysql_error());
$k=0;
while ($k<mysql_num_rows($az))
{
$zz=mysql_fetch_row($az);
$produit=mysql_query("select * from 'piece' where num_piece='$zz[1]'")or die (mysql_error());
$pro=mysql_fetch_row($produit);
echo "(".$zz[3]." X ".$pro[5]." DA) -------- ".$pro[2]."<br>";
$k=$k+1;
};echo"
<br><b>Montant Total à payer : </b>".$ligne[2]." DA
</td>
<td>
<div id='commande_Non'><a><b>Commande Rejetée<br>
Veuillez contacter le vendeur</b></a>
</div>
</td></tr>
</table>";
echo"";
echo"<HR>";
$i=$i+1;
}
mysql_free_result($req);
mysql_close($connection); //Puis on se déconnecte
?>
Svp aider moi c vraiment urgent
Merci