lalnfl Posted February 13, 2011 Share Posted February 13, 2011 $sql_get_match = mysql_query("SELECT length FROM Match_1v1 WHERE show_id='$show_id'"); $get_match = array_sum(mysql_fetch_array($sql_get_match)); I have two fields in the database with length's of 31 and 29, but it comes out as a total of 58. What am I doing wrong? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 13, 2011 Share Posted February 13, 2011 29 + 29 = 58. You're getting the sum of the 2 array elements returned by mysql_fetch_array() for the last record returned. mysql_fetch_array() returns both an associative and an enumerated array. Quote Link to comment Share on other sites More sharing options...
lalnfl Posted February 13, 2011 Author Share Posted February 13, 2011 What would my solution be then to get 60? Quote Link to comment Share on other sites More sharing options...
lalnfl Posted February 13, 2011 Author Share Posted February 13, 2011 $sql_get_match = mysql_query("SELECT SUM(length) FROM Match_1v1 WHERE show_id='$show_id'"); $get_match = mysql_result($sql_get_match, 0); This seems to fix the problem. 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.