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 Link to comment https://forums.phpfreaks.com/topic/64087-this-is-weird/ Share on other sites More sharing options...
ToonMariner Posted August 9, 2007 Share Posted August 9, 2007 try using $row['networking']; Link to comment https://forums.phpfreaks.com/topic/64087-this-is-weird/#findComment-319374 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! Link to comment https://forums.phpfreaks.com/topic/64087-this-is-weird/#findComment-319379 Share on other sites More sharing options...
Neptunus Maris Posted August 9, 2007 Author Share Posted August 9, 2007 That did not work Link to comment https://forums.phpfreaks.com/topic/64087-this-is-weird/#findComment-319380 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 />"; } ?> ? Link to comment https://forums.phpfreaks.com/topic/64087-this-is-weird/#findComment-319383 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 Link to comment https://forums.phpfreaks.com/topic/64087-this-is-weird/#findComment-319387 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... Link to comment https://forums.phpfreaks.com/topic/64087-this-is-weird/#findComment-319396 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(). Link to comment https://forums.phpfreaks.com/topic/64087-this-is-weird/#findComment-319440 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. Link to comment https://forums.phpfreaks.com/topic/64087-this-is-weird/#findComment-319453 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.