General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 7th, 2003, 09:14 PM
Alicia Alicia is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 116 Alicia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 27 m 49 sec
Reputation Power: 6
capture value prob

Hi guys,

I tried to send these info to my mailbox by using mail function... but i can't get the value for the totalCost in my email.. can you guys check whats wrong with my code ??

my code:

if($_SESSION['mem'] == "assc")
{
while($row = mysql_fetch_array($result))
{
$totalCost += ($row["qty"] * $row["associate"]);

$contents .="Item: {$row['itemName']}\n";
$contents .="Name: {$row['itemDesc']}\n";
$contents .="Price per item: USD";
$contents .= number_format($row['associate'], 2,'.', '.') . "\n";
$contents .="Quantity: {$row['qty']}\n";
}
$contents .="Total amount: USD {$totalCost} \n";
}
elseif ($_SESSION['mem'] == "dist")
{
while($row = mysql_fetch_array($result))
{
$totalCost += ($row["qty"] * $row["distributor"]);
$contents .="Item: {$row['itemName']}\n";
$contents .="Name: {$row['itemDesc']}\n";
$contents .="Price per item: USD";
$contents .= number_format($row['associate'], 2,'.', '.') . "\n";
$contents .="Quantity: {$row['qty']}\n";
}
$contents .="Total amount: USD {$totalCost} \n";
}
else
{
while($row = mysql_fetch_array($result))
{
$contents .="Item: {$row['itemName']}\n";
$contents .="Name: {$row['itemDesc']}\n";
$contents .="Price per item: USD";
$contents .= number_format($row['associate'], 2,'.', '.') . "\n";
$contents .="Quantity: {$row['qty']}\n";
}
$contents .="Total amount: USD {$totalCost} \n";
}

--- mail function ()

PLease advise.

Reply With Quote
  #2  
Old December 8th, 2003, 06:56 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
My guess is that your code is always skipping the if and the elseif and going to the third block, in which you're doing nothing to set $totalCost. Since you don't initialize it (to 0, say) outside the if-elseif-else block, no value comes across.

Reply With Quote
  #3  
Old December 8th, 2003, 07:44 PM
Alicia Alicia is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 116 Alicia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 27 m 49 sec
Reputation Power: 6
Is that mean i should put something like $totalCoast = o before the if-else statement ?

Reply With Quote
  #4  
Old December 9th, 2003, 11:16 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Yes, try setting $totalCost to 0 before the if-else statement.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > capture value prob


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT