I cannot get the sum in the database. please help me to see it!
$ Xmpc_id = '4 '; /*************************************** * **/$ query1 = mssql_query ("select * from tb_xm where xm_pcid = '$ xmpc_id '"); while ($ myrow1 = explain ($ query1) {$ query12 = mssql_query ("select sum (xmpf_small_zf) as zf from tb_xmpf where xmpf_xm = '$ myrow2 [xm_name]'"); echo $ myrow1 [xm_name]; echo $ query12; echo "quantity:"; echo mssql_num_rows ($ query12); echo "Total score :"; while ($ myrow12 = mssql_fetch_array ($ query12) {echo $ myrow12 [zf];}
Reply to discussion (solution)
Print the SQL statement and put it in phpmyadmin to execute the following:
Is echo $ myrow12 [zf]; no output
Still no output?
It is echo $ myrow12 [zf]; there is no output, and other outputs are there.
What is the result of directly placing $ query12 content on the database management tool?
I changed the program again. it seems that the database content can be read under while ($ myrow12 = mssql_fetch_array ($ query12). I also want to ask how to solve the mean value?
Isn't there an avg function?
Thank you. I found it, but the obtained value cannot be written to the database? $ Query3 error. why?
$ Query1 = mssql_query ("select * from tb_xm where xm_pcid = '$ xmpc_id'"); while ($ myrow1 = mssql_fetch_assoc ($ query1) {echo $ myrow1 [xm_name]; $ query2 = mssql_query ("select sum (xmpf_small_zf) as zf from tb_xmpf where xmpf_xm = '$ myrow1 [xm_name]'"); // echo $ query2; echo "Total score :"; while ($ myrow2 = mssql_fetch_assoc ($ query2) {echo $ myrow2 [zf]; $ query3 = mssql_query ("update tb_xm set xm_zf = '$ myrow2 [zf] 'Where xm_name =' $ myrow1 [xm_name] '");} $ query4 = mssql_query ("select avg (xmpf_small_zf) as avgf from tb_xmpf where xmpf_xm = '$ myrow1 [xm_name]'"); // echo $ query4; echo "Average score :"; while ($ myrow4 = mssql_fetch_assoc ($ query4) {echo $ myrow4 [avgf]; $ query5 = mssql_query ("update tb_xm set xm_avg = '$ myrow4 [avgf] 'Where xm_name =' $ myrow1 [xm_name] '");}