I cannot get the sum in the database. please help me to see it!

Source: Internet
Author: User
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] '");}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.