|
Posted by Ehsan on 04/01/06 17:04
Hi,
mail_format_cart() function is returning $title, which is basically
giving you only one item right? Well the way function is executed it
will return the last index of the array $_SESSION['cart']. WHY? Because
in your foreach() you are running query, fetching data and assigning
$item['title'] to $title. So what is basically happening here is as
follows:
+ Starts Loop Cycle 1
+ $title is assigned with first value found in $item['title'], e.g.
Item One
+ Starts Loop Cycle 2
+ $title is assigned AGAIN with the second value found in
$item['title'], e.g. Item Two
.....
+ Start the Last Loop Cycle
+ $title is assigned with the LAST value found in $item['title'],
e.g. ITEM LAST
So returning $title from the function will give your mail ITEM LAST
only. If you write a code like:
$a = "My";
....some more code
$a = "Your";
....some more code
$a = "Our";
echo $a will give us Our. Not My nor Your.
How to get the proper list of items? You can simply make $title an
array to assign values to it. That is, rather than writing $title =
$item['title']; you write:
$title[] = $item['title'];
If you do the above then you will have to run another foreach loop in
mail_order() function. To avoid this you can do this instead, which I
think is very good. Don't even assign it to an array as mentioned
above. Try writing:
$title .= $item['title'] . "\n\n";
Hope this will help. Sorry for the long and big explanation. Thought it
will help.
Thanks and God Bless!!
Ehsan
http://ehsan.bdwebwork.com
[Back to original message]
|