Good evening, you need to count and display the sum of all values in the 1st field in mysql. How to do it better? calculate immediately in mysql or print first and let php consider?
1 answer
SELECT SUM(название поля) FROM имя таблицы WHERE условие $row=mysql_fetch_array($result); echo $row[0]; - Thanks, but ... $ result = mysql_query ("SELECT count (amount) FROM bank"); And then how to output the
$result? Ifechodirectly, then displaysResource id #5. If you skip throughmysql_fetch_arrayand then output - it turns outArray:) - Denis Masster - The question you have is different, well, think a little and add the code. - Artem
- Yes, I already managed to understand it), but it derived the number of lines, but I needed the sum of the entire field, i.e. I have two lines, in the first 20 in the second 5 and this in the amount field is necessary so that 25 will be printed out :) - Denis Masster
- perhaps something with the type of field. write all fields with their types. - Artem
- 4 fields: id - int (10) name - warchar amount - int (10) date - date - Denis Masster
|