|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
randj Smarty n00b
Joined: 13 Feb 2013 Posts: 1
|
Posted: Wed Feb 13, 2013 3:27 pm Post subject: while($row = mysql_fetch_assoc. . . -> 2 array anstatt nu |
|
|
Hallo,
für eine kleines bestellformular will ich das zwischen-total pro artikel errechnen.
in der DB habe ich preis, anzahl, und den ganzen rest. DB ist OK. nun möchte ich das subtotal ausrechnen und an Smarty übergeben. . .
er macht mir aber zwei array anstelle von nur einer :
$arrayShop = array();
while($row = mysql_fetch_assoc($query)){
$arrayShop[] = $row;
$arrayShop["subtotal"] .= $row["prix"] * $row["quantite"];
}
var_dump ($arrayShop);
$smarty->assign("res", $arrayShop);
der var_dump gibt bereits an, dass 2arrays da sind. . . und ich weiss nicht, wie ich diese in Smarty verbinden könnte, darum möchte ich eine einzige Array. . . :
array(2) { [12]=> array(6) { ["id_panier"]=> string(2) "90" ["id_session"]=> string(26) "2qq6v51o7afojm4da6pg9n2iq5" ["id"]=> string(2) "12" ["quantite"]=> string(1) "3" ["titel"]=> string(54) "L’Architecture du Destin - selon la voie des nombres" ["prix"]=> string(5) "32.00" } ["subtotal"]=> string(2) "96" }
das ergebnis des subtotal stimmt.
für tipps und tricks danke ich schon mal im voraus.
beste grüsse
jurg |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Feb 13, 2013 8:03 pm Post subject: |
|
|
Ich glaube du willst dies
Code: | while($row = mysql_fetch_assoc($query)){
$row["subtotal"] = $row["prix"] * $row["quantite"];
$arrayShop[] = $row;
} |
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|