User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 423,948 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,184 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 583 | Replies: 1
Reply
Join Date: Sep 2006
Posts: 10
Reputation: cty is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
cty cty is offline Offline
Newbie Poster

Loop Problem,plz help

  #1  
Dec 18th, 2006
$totalCost=0;
while($row = $result->fetch_assoc())
{
$totalCost+=$row["price"];
------------------------------
--->why the $totalCost always is 0?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2006
Location: London
Posts: 42
Reputation: UrbanSky is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 4
UrbanSky UrbanSky is offline Offline
Light Poster

Re: Loop Problem,plz help

  #2  
Dec 18th, 2006
does row["price"] have a value in it? Php let you assign empty array items. Try add echo $row['price'] to the loop and make sure that it is not empty.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 6:12 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC