Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

while($row = mysql_fetch_assoc. . . -> 2 array anstatt nu

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
randj
Smarty n00b


Joined: 13 Feb 2013
Posts: 1

PostPosted: Wed Feb 13, 2013 3:27 pm    Post subject: while($row = mysql_fetch_assoc. . . -> 2 array anstatt nu Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Feb 13, 2013 8:03 pm    Post subject: Reply with quote

Ich glaube du willst dies

Code:
while($row = mysql_fetch_assoc($query)){
 $row["subtotal"] = $row["prix"] * $row["quantite"];
$arrayShop[] = $row;
}
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP