Neptunus Maris Posted August 9, 2007 Share Posted August 9, 2007 This is all the sudden not working $networking = 0; //i did all the database selection...bla bla bla while ($row = mysql_fetch_array($result)) { $networking += $row[networking]; } //end while print "$networking"; I'm try to increment the value of $networking, which starts at 0 then while loops through database results, which ARE integers in their fields i.e. `networking` tinyint(1) unsigned NOT NULL default ''. Say if I have 50 table rows for that. I want to loop through the `networking` field to count all (integer values can be anywhere from 0-99) and add them to the $networking variable as displayed in the while() as $networking += $row[networking]; It is not doing that $networking just shows up as 0. Does anyone know anything about this. Thanks for the help in advance! -Neptune Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 9, 2007 Share Posted August 9, 2007 try using $row['networking']; Quote Link to comment Share on other sites More sharing options...
Neptunus Maris Posted August 9, 2007 Author Share Posted August 9, 2007 try using $row['networking']; Ok...but the single quotes really don't matter in most cases but it never hurts to try. Thanks! Quote Link to comment Share on other sites More sharing options...
Neptunus Maris Posted August 9, 2007 Author Share Posted August 9, 2007 That did not work Quote Link to comment Share on other sites More sharing options...
trq Posted August 9, 2007 Share Posted August 9, 2007 What is the output of... <?php while ($row = mysql_fetch_array($result)) { echo $row['networking']."<br />"; } ?> ? Quote Link to comment Share on other sites More sharing options...
Neptunus Maris Posted August 9, 2007 Author Share Posted August 9, 2007 What is the output of... <?php while ($row = mysql_fetch_array($result)) { echo $row['networking']."<br />"; } ?> ? I've got nothing for some odd reason Quote Link to comment Share on other sites More sharing options...
Neptunus Maris Posted August 9, 2007 Author Share Posted August 9, 2007 Well I guess this can't be done then... Quote Link to comment Share on other sites More sharing options...
trq Posted August 9, 2007 Share Posted August 9, 2007 Of course it can be done. Your query is more then likely failing, we need to see more code. In particular, your query and call to mysql_query(). Quote Link to comment Share on other sites More sharing options...
dewey_witt Posted August 9, 2007 Share Posted August 9, 2007 Try to use $networking = $row[networking]; instead w/o the + sign. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.