$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] ');}