tomas.hortlax Posted March 12, 2010 Share Posted March 12, 2010 I know...it's very easy.But for me ... not!OKcode: echo $no3 ;// Print total $total1 = mysql_query ( "SELECT SUM ('D') FROM databas WHERE A=$no3"); $total2 = mysql_fetch_array ($total1); $total3 = $total2['SUM(D)']; echo 'Value on this serie is' . $total3 ; I have put in "echo $no3;" only to check if there is a value on it. Yes it is.But I dont get anything at $total3. What are I doing wrong?/Tomas Link to comment Share on other sites More sharing options...
Synook Posted March 12, 2010 Share Posted March 12, 2010 Try giving the SUM() column an alias and using that. Also, check mysql_num_rows() - are you sure that it is matching any rows? Also, check mysql_error() to see whether your query has an error in it. $total1 = mysql_query ( "SELECT SUM('D') AS sum FROM databas WHERE A=$no3"); $total2 = mysql_fetch_array ($total1); $total3 = $total2['sum']; echo 'Value on this serie is' . $total3; Link to comment Share on other sites More sharing options...
tomas.hortlax Posted March 12, 2010 Author Share Posted March 12, 2010 Try giving the SUM() column an alias and using that. Also, check mysql_num_rows() - are you sure that it is matching any rows? Also, check mysql_error() to see whether your query has an error in it. $total1 = mysql_query ( "SELECT SUM('D') AS sum FROM databas WHERE A=$no3"); $total2 = mysql_fetch_array ($total1); $total3 = $total2['sum']; echo 'Value on this serie is' . $total3; No error. And Yes. I know it matches a couple of rows.But...I put in this row "echo mysql_num_rows($total1);" and it does not print anything.../Tomas Link to comment Share on other sites More sharing options...
justsomeguy Posted March 12, 2010 Share Posted March 12, 2010 Field names do not go in quotes, you're telling it to sum the letter "D". Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.