|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
||||
|
||||
|
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.
|
|
#3
|
|||
|
|||
|
Is that mean i should put something like $totalCoast = o before the if-else statement ?
|
|
#4
|
||||
|
||||
|
Yes, try setting $totalCost to 0 before the if-else statement.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > capture value prob |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|