Hello everyone,
Im new here. I'm not new to web design but a bit new to PHP. I really need some help with this. I have an email script that sends a bunch of user choices to me.

The choices ware one or more and are sent to the email page via Sessions (entered and submitted two pages before).

Here is the email section of the code.

$to = "my@email.com";
$subject = "Online order recieved " ;

$uni_order = "$TotalShirts_unisex $unisex_colour Unisex T-Shirts";
$mp_order = "$TotalShirts_mpolo $mpolo_colour Men's Polo Shirts";
$fp_order ="$TotalShirts_fpolo $fpolo_colour Women's Polo Shirts";
$ks_order = "$TotalShirts_kshirt $kshirt_colour Kids T-Shirts";
$spag_order = "$TotalShirts_spag $spag_colour Spagetti Tank Tops";
$mringer_order = "$TotalShirts_mringer $mringer_colour Men's Ringer T-Shirts";
$fringer_order = "$TotalShirts_fringer $fringer_colour Women's Ringer T-Shirts";
$fs_order = "$TotalShirts_fshirt $fshirt_colour Ladies T-Shirts (Baby-T's)";
$cap_order = "$caps_amt $caps_colour Cotton Twill Caps</p>";
$bib_order = "$bibs_amt Bibs";
$apron_order = "$aprons_amt Aprons";
$ban_order = "$bandana_amt Bandanas";

$msg = "Instant Quote Order from:\n COMPANY: $company\n TELEPHONE: $tele\n EMAIL: $from \nas follows:\n
$uni_order\n
$mp_order\n
$fp_order\n
$ks_order\n
$spag_order\n
$mringer_order\n
$fringer_order\n
$fs_order\n
$cap_order\n
$bib_order\n
$apron_order\n
$ban_order\n
download file at: http://www.iyajamaica.com/$show_link\n
Additional Information or Instructions:\n*************************************************\n$instr";

$headers = "From: $from \r\nReply-To: toocoded@gmail.com";
mail("$to", "$subject", "$msg", "$headers");

This is the result...

Instant Quote Order from:
COMPANY: Name of Company
TELEPHONE:
EMAIL:
as follows:

120 gold Unisex T-Shirts

0 Men's Polo Shirts

15 Women's Polo Shirts

0 Kids T-Shirts

0 Spagetti Tank Tops

Men's Ringer T-Shirts

Women's Ringer T-Shirts

0 Ladies T-Shirts (Baby-T's)

0 0 Cotton Twill Caps</p>

0 Bibs

0 Aprons

0 Bandanas

download file at:

Additional Information or Instructions:
*************************************************

What I need the email script to do is to only display the Items selected those two pages ago (in green). Can anyone help me out please. I hope i explained my problem properly.

You could use conditional statements, a quick example:

$color = "000000";

then for each:

if ($TotalShirts_unisex > 0) { $color = "#009900"; }
$uni_order = "<font color='$color'>$TotalShirts_unisex $unisex_colour Unisex T-Shirts</font>";

you could also just not show an option when it's zero...so:

if ($TotalShirts_unisex > 0) {
$uni_order = "$TotalShirts_unisex $unisex_colour Unisex T-Shirts";
}

----------------------EDIT---------------------------
Sorry just realised what you were asking about showing them, did I answer that ok?

You know how to recall the variables from sessions, yes?

So your saying declare the variables within If Statements and only if they pass the condition is when they would be available? That sounds like a plan.

I'll try it and let you know what happens. Thanks a lot sourcez.

Even thought the conditionally declaring the variables may help with displaying only the selected values. How will I solve the spacing/newline issue in the email body ($msg variable) ?

Just change

$uni_order = "$TotalShirts_unisex $unisex_colour Unisex T-Shirts";
#
$uni_order\n

to

$uni_order = "$TotalShirts_unisex $unisex_colour Unisex T-Shirts\n";
#
$uni_order

That will make sure you have the right number of line breaks - as you're also making them conditional by including them in the variables above.

Your a genius man. I'm doing the fixes now, will let you know how it turns out.

Thanks again.

How did it go? You set it all up ok?

Im still at it, just setting up a few more sessio variables and getting them to work. But so far so good, I tested your handiwork on one of the selections and it works just as you said. you can check it out www.iyajamaica.com/products

Your help is so much appreciated sourcez. Everything working great.
Thanks :)

Glad you got it working ok :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.