Unable to get the sum value in the database, Lao God help me to see!

Source: Internet
Author: User
$XMPC _id= ' 4 ';/******************************************/$query 1=mssql_query ("select * from TB_XM where xm_pcid= ' $ Xmpc_id ' ") ($myrow 1=mssql_fetch_assoc ($query 1)) {$query 12=mssql_query (" Select sum (XMPF_SMALL_ZF) as ZF from Tb_ Xmpf where xmpf_xm= ' $myrow 2[xm_name] ' "), echo $myrow 1[xm_name];echo $query 12;echo" Quantity: "; Echo mssql_num_rows ($query 12) echo "Total value:"; while ($myrow 12=mssql_fetch_array ($query)) {echo $myrow 12[zf];}


Reply to discussion (solution)

Print out the SQL statement and put it in phpMyAdmin to perform the following

is Echo $myrow 12[ZF]; No output
Or are there no outputs?

is Echo $myrow 12[ZF]; No output, other outputs are available.

What is the result of putting $QUERY12 content directly on a database management tool?

I changed the program, seemingly while ($myrow 12=mssql_fetch_array ($query 12) to read the contents of the database, I would also like to ask how to solve the mean?

Isn't there an AVG function?

Thank you, I found it, but the resulting value cannot be written to the database? Say $query3 wrong, this is why AH?

$query 1=mssql_query ("select * from TB_XM where xm_pcid= ' $xmpc _id '"), while ($myrow 1=mssql_fetch_assoc ($query 1)) {echo $ Myrow1[xm_name]; $query 2=mssql_query ("Select sum (XMPF_SMALL_ZF) as ZF from Tb_xmpf where xmpf_xm= ' $myrow 1[xm_name]") ;//echo $query 2;echo "Total score:" while ($myrow 2=mssql_fetch_assoc ($query 2)) {echo $myrow 2[zf]; $query 3=mssql_query ("Update TB_XM set xm_zf= ' $myrow 2[zf] ' where xm_name= ' $myrow 1[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.