Reply to Re: Please, need help with a mail function

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация