desjardins2010 Posted January 10, 2011 Share Posted January 10, 2011 hi all I have this can someone help me I'm trying to get a total cost <?php //inventory report printable total value in stock $connect = mysql_connect('*******') or die (mysql_error()); mysql_select_db('fminventory') or die (mysql_error()); $query = mysql_query("SELECT SUM(cost) FROM cars"); $query2 = mysql_fetch_array($query); echo $query2; ?> Quote Link to comment Share on other sites More sharing options...
guyfromfl Posted January 10, 2011 Share Posted January 10, 2011 You are trying to access the data wrong. try echo $query2[0]; The mysql_fetch_array returns the data into an array. The first element of the array is 0. Also, query2 should probably be called something like result, to keep it less confusing. Quote Link to comment Share on other sites More sharing options...
desjardins2010 Posted January 10, 2011 Author Share Posted January 10, 2011 thanks that worked... 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.