Aide moi SVP

khaledbell Messages postés 6 Date d'inscription mardi 29 juillet 2008 Statut Membre Dernière intervention 16 novembre 2010 - 14 nov. 2010 à 16:53
khaledbell Messages postés 6 Date d'inscription mardi 29 juillet 2008 Statut Membre Dernière intervention 16 novembre 2010 - 16 nov. 2010 à 10:38
j'ai un table de base de donnée dans ce tableau
il y a un colonne prix_total je veux calculer la somme de colonne prix_total je suis travail en cakephp merci

10 réponses

cod57 Messages postés 1653 Date d'inscription dimanche 7 septembre 2008 Statut Membre Dernière intervention 11 septembre 2013 19
14 nov. 2010 à 16:57
Bonjour
le code ? s.t.p. !
la requête ?
a++
0
khaledbell Messages postés 6 Date d'inscription mardi 29 juillet 2008 Statut Membre Dernière intervention 16 novembre 2010
14 nov. 2010 à 17:56
<?php echo '<td width= "15">'.$this->Html->link('Ajouter',array('controller'=>'livres', 'action'=>'add')).
'</td>';
?>



<?php
if(empty($livres)){
echo "Pour ajouter Cliquez ici";
echo'
';

}
else {
?>
<table border='2'>
<tr>
<td width="20"> id </td>
<td width ="80">produit</td>
<td width= "70"> N de produit </th>
<td colspan ="2" width= "50"> Prix </td>
<td width ="100">la date</td>
<td width= "60"> Prix Total </td>
<td colspan ="3" align= "center"> action </td>
<tr>
<?php foreach ($livres as $livre){
echo '<tr>';
echo '<td width ="20">'.$livre['Livre']['id'].'</td>';
echo '<td width= "80"> '.$livre['Livre']['produit'].' </td>';

echo '<td>'.$livre['Livre']['N_produit'].'</td>';
echo '<td width ="50">'.$livre['Livre']['prix'].'</td>';
echo '<td width= "20"> '.$livre['Livre']['Mo'].' </td>';
echo '<td>'.$livre['Livre']['date'].'</td>';
echo '<td>'.$livre['Livre']['N_produit']*$livre['Livre']['prix'].'</td>';

echo '<td width ="15">'.$this->Html->link('Supp',array('controller'=>'livres', 'action'=>'delete', $livre['Livre']['id']),
array('escape' => false)).
'</td>';
echo '<td width="15">'.$this->Html->link('Mod',array('controller'=>'livres', 'action'=>'edit', $livre['Livre']['id'])).
'</td>';
echo '</tr>';

}
?>
colonne de prix_total cantine des totale de chaque lien, moi je veux calculer tout ce qui existe dans ce colonne merci
0
cod57 Messages postés 1653 Date d'inscription dimanche 7 septembre 2008 Statut Membre Dernière intervention 11 septembre 2013 19
14 nov. 2010 à 19:07
bonsoir


<?php echo '<td width= "15">'.$this->Html->link('Ajouter',array('controller'=>'livres', 'action'=>'add')).
'</td>';
?>



<?php
if(empty($livres)){
echo "Pour ajouter Cliquez ici";
echo'
';

}
else {
?>
<table border='2'>
<tr>
<td width="20"> id </td>
<td width ="80">produit</td>
<td width= "70"> N de produit </th>
<td colspan ="2" width= "50"> Prix </td>
<td width ="100">la date</td>
<td width= "60"> Prix Total </td>
<td colspan ="3" align= "center"> action </td>
<tr>
<?php foreach ($livres as $livre){
echo '<tr>';
echo '<td width ="20">'.$livre['Livre']['id'].'</td>';
echo '<td width= "80"> '.$livre['Livre']['produit'].' </td>';

echo '<td>'.$livre['Livre']['N_produit'].'</td>';
echo '<td width ="50">'.$livre['Livre']['prix'].'</td>';
echo '<td width= "20"> '.$livre['Livre']['Mo'].' </td>';
echo '<td>'.$livre['Livre']['date'].'</td>';
echo '<td>'.$livre['Livre']['N_produit']*$livre['Livre']['prix'].'</td>';

echo '<td width ="15">'.$this->Html->link('Supp',array('controller'=>'livres', 'action'=>'delete', $livre['Livre']['id']),
array('escape' => false)).
'</td>';
echo '<td width="15">'.$this->Html->link('Mod',array('controller'=>'livres', 'action'=>'edit', $livre['Livre']['id'])).
'</td>';
echo '</tr>';

$somme=$livre['Livre']['N_produit']*$livre['Livre']['prix'];
$i=count($somme);
for($j=0;$j<$i;$j++){
$res=$res+$somme;
}
echo '
total : '.$res.'
';
}
0
khaledbell Messages postés 6 Date d'inscription mardi 29 juillet 2008 Statut Membre Dernière intervention 16 novembre 2010
15 nov. 2010 à 01:11
merci cod57
------------------------------------
_______________________________________________
id | produit |N de produit | prix |prix total |
| | | | |
------------------------------------------------
1 | portable| 20 | 1000 | 20000 |
| | | | |
------------------------------------------------
2 | pc | 40 | 800 | 32000 |
| | | | |
------------------------------------------------
je veux calcule colonne prix total(20000+32000)

mais votre code que vous avez me donne est affiche moi une erreur
Notice (8): Undefined variable: res [APP\views\livres\index.ctp, line 52]
merci
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cod57 Messages postés 1653 Date d'inscription dimanche 7 septembre 2008 Statut Membre Dernière intervention 11 septembre 2013 19
15 nov. 2010 à 09:59
Bonjour
pour l'erreur
Notice (8): Undefined variable: res [APP\views\livres\index.ctp, line 52]
il faut juste définir la variable $res avant le foreach

je vous propose une alternative
tester ce code
<?php

$livres=array(
        array('id'=>'1','produit'=>'auto','N_produit'=>'20','prix'=>'5','date'=>'2010-10-10') ,
        array('id'=>'2','produit'=>'auto2','N_produit'=>'50','prix'=>'5','date'=>'2010-10-10') ,
        array('id'=>'3','produit'=>'auto3','N_produit'=>'30','prix'=>'5','date'=>'2010-10-10') 
        );

$res="";

foreach ($livres as $livre){ 


$somme=$livre['N_produit']*$livre['prix'];
$i=count($somme);
for($j=0;$j<$i;$j++){
$res=$res+$somme;
}

} 

echo  '
'.$res.'
';
?> 
0
khaledbell Messages postés 6 Date d'inscription mardi 29 juillet 2008 Statut Membre Dernière intervention 16 novembre 2010
15 nov. 2010 à 10:21
merci cod57
thank you very much
0
cod57 Messages postés 1653 Date d'inscription dimanche 7 septembre 2008 Statut Membre Dernière intervention 11 septembre 2013 19
15 nov. 2010 à 10:23
Please close the post
great for you
0
khaledbell Messages postés 6 Date d'inscription mardi 29 juillet 2008 Statut Membre Dernière intervention 16 novembre 2010
15 nov. 2010 à 22:03
bonsoir cod57,
comment affiche la somme de colonne prix total
sans la boucle car il afffiche moi la somme de dirnére lien ajouter
comme ca
id / Produit / Prix / N_produit / Prix total
1 / Portable / 20 / 10 / 200
2 / Tub / 200 / 10 / 2000
3 / Pc / 80 / 20 / 1600
4 / Min pc / 20 / 1000 / 20000
5 / Ram / 10 / 10 / 100
6 / Usb / 60 / 3 / 180


total : 200

total : 2200

total : 3800

total : 23800

total : 23900

total : 24080
0
cod57 Messages postés 1653 Date d'inscription dimanche 7 septembre 2008 Statut Membre Dernière intervention 11 septembre 2013 19
15 nov. 2010 à 23:14
bonsoir


<?php

$livres=array(
        array('id'=>'1','produit'=>'auto','N_produit'=>'20','prix'=>'5','date'=>'2010-10-10') ,
        array('id'=>'2','produit'=>'auto2','N_produit'=>'50','prix'=>'5','date'=>'2010-10-10') ,
        array('id'=>'3','produit'=>'auto3','N_produit'=>'30','prix'=>'5','date'=>'2010-10-10') 
        );

$res="";

foreach ($livres as $livre){ 


$somme=$livre['N_produit']*$livre['prix'];
$i=count($somme);
for($j=0;$j<$i;$j++){
echo $somme .'
';
$res=$res+$somme;
}
} 

echo  '
'.$res.'
';
?> 


a++
0
khaledbell Messages postés 6 Date d'inscription mardi 29 juillet 2008 Statut Membre Dernière intervention 16 novembre 2010
16 nov. 2010 à 10:38
merci
0
Rejoignez-nous