par
helloworld » 09 févr. 2011, 11:13
Bonjour à tous, étant débutant en php, j'ai quelques soucis avec les arrondies, et faire la somme de plusieurs montant, voici une partie du code :
<tr>
<th>Quantité</th>
<th>Produit</th>
<th>Montant</th>
</tr>
<?php
$idmembre = $_SESSION['id'];
$sql =
"select * from lignecommande, produit where lignecommande.idproduit=produit.idproduit and idmembre=$idmembre and etat='encours';";
$requete=mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($requete) > 0) {
while ($resultat = mysql_fetch_assoc($requete)){
echo"<tr>
<td>".$resultat['qte'].
"</td>
<td>".$resultat['designation'].
"</td>
<td>".$resultat['qte']*$resultat['prixkg']*$resultat['poids'].
"</td> //ici cela me renvoi le montant d'une ligne_commande, je dois l'arrondir avec la fonction round() mais cela me pose problème
</tr>";
}
}
else{
echo" Votre panier est vide";
}
?>
<tr>
<th>Total</th>
<td></td>
<td colspan=2>............</td>
// ici je souhaiterais compter chaque montant de toute les lignes_commande retournées. Peut-être utiliser un compteur, mais je n'ai pas d'idee ..
</tr>
<tr>
<th>Quantité</th>
<th>Produit</th>
<th>Montant</th>
</tr>
<?php
$idmembre = $_SESSION['id'];
$sql = "select * from lignecommande, produit where lignecommande.idproduit=produit.idproduit and idmembre=$idmembre and etat='encours';";
$requete=mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($requete) > 0) {
while ($resultat = mysql_fetch_assoc($requete)){
echo"<tr>
<td>".$resultat['qte']."</td>
<td>".$resultat['designation']."</td>
<td>".$resultat['qte']*$resultat['prixkg']*$resultat['poids']."</td>
</tr>";
}
}
else{
echo" Votre panier est vide";
}
?>
<tr>
<th>Total</th>
<td></td>
<td colspan=2>.......</td>
</tr>
Quelqu'un peut il m'aider ?

Bonjour à tous, étant débutant en php, j'ai quelques soucis avec les arrondies, et faire la somme de plusieurs montant, voici une partie du code :
<tr>
<th>Quantité</th>
<th>Produit</th>
<th>Montant</th>
</tr>
[color=#FF0000]<?php[/color]
$idmembre = $_SESSION['id'];
$sql =[color=#808080] "select * from lignecommande, produit where lignecommande.idproduit=produit.idproduit and idmembre=$idmembre and etat='encours';"[/color];
$requete=mysql_query($sql) or die(mysql_error());
[color=#0040FF]if[/color] (mysql_num_rows($requete) > 0) {
[color=#0000FF]while[/color] ($resultat = mysql_fetch_assoc($requete)){
[color=#0000FF]echo[/color][color=#808080]"<tr>
<td>"[/color].$resultat['qte'].[color=#808080]"</td>
<td>"[/color].$resultat['designation'].[color=#808080]"</td>
<td>"[/color].$resultat['qte']*$resultat['prixkg']*$resultat['poids'].[color=#808080]"</td>[/color] [color=#00BF00] //ici cela me renvoi le montant d'une ligne_commande, je dois l'arrondir avec la fonction round() mais cela me pose problème[/color]
[color=#808080]</tr>"[/color];
}
}
[color=#0000FF]else[/color]{
[color=#0000FF]echo[/color][color=#808080]" Votre panier est vide"[/color];
}
[color=#FF0000]?>[/color]
<tr>
<th>Total</th>
<td></td>
<td colspan=2>............</td>[color=#00BF00]// ici je souhaiterais compter chaque montant de toute les lignes_commande retournées. Peut-être utiliser un compteur, mais je n'ai pas d'idee ..[/color]
</tr>
[php] <tr>
<th>Quantité</th>
<th>Produit</th>
<th>Montant</th>
</tr>
<?php
$idmembre = $_SESSION['id'];
$sql = "select * from lignecommande, produit where lignecommande.idproduit=produit.idproduit and idmembre=$idmembre and etat='encours';";
$requete=mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($requete) > 0) {
while ($resultat = mysql_fetch_assoc($requete)){
echo"<tr>
<td>".$resultat['qte']."</td>
<td>".$resultat['designation']."</td>
<td>".$resultat['qte']*$resultat['prixkg']*$resultat['poids']."</td>
</tr>";
}
}
else{
echo" Votre panier est vide";
}
?>
<tr>
<th>Total</th>
<td></td>
<td colspan=2>.......</td>
</tr>[/php]
Quelqu'un peut il m'aider ? :priere: :priere: