How can I query the data in the database with one condition, and then count the total amount of data stored in another field. there is a requirement that I first display Runan building and then count how many computers Runan building has received.
Reply to discussion (solution)
It is enough to accumulate data during reading.
It is enough to accumulate data during reading.
Please let me know more... thank you!
$ SQL = "select sum (number) as total where area = 'runan mansion '"; $ result = mysql_query ($ SQL); while ($ row = mysql_fetch_array ($ result )) {$ total = $ row ['total'];} echo "Runan building :". $ total. "platform ";
How can this problem be solved?
Array
Array (
Array ('A', 1 ),
Array ('A', 2 ),
Array ('B', 1 ),
Array ('C', 1 ),
Array ('A', 1 ),
)
We need to sum the second column by the first column. what do you do?
How can this problem be solved?
Array
Array (
Array ('A', 1 ),
Array ('A', 2 ),
Array ('B', 1 ),
Array ('C', 1 ),
Array ('A', 1 ),
)
We need to sum the second column by the first column. what do you do?
$ Query = "select * from tbl_apply_register where area = 'runan mansion '"; $ SQL = mysql_query ($ query); while ($ row = mysql_fetch_array ($ SQL )) {$ tmp [] = $ row [number];} echo array_sum ($ tmp );
$ SQL = "select sum (number) as total where area = 'runan mansion '"; $ result = mysql_query ($ SQL); while ($ row = mysql_fetch_array ($ result )) {$ total = $ row ['total'];} echo "Runan building :". $ total. "platform ";
$ Query = "select * from tbl_apply_register where area = 'runan mansion '"; $ SQL = mysql_query ($ query); while ($ row = mysql_fetch_array ($ SQL )) {$ tmp [] = $ row [number];} echo array_sum ($ tmp );
$ SQL = "select sum (number) as total where area = 'runan mansion '";
Sorry, I have an extra where
Your method is essentially the same as mine, but I calculate it directly in the database.