I set up two tables, table one for the project table TB_XM mainly has the project batch Xm_pcid and the project name Xm_name, table two is the project score table mainly has the project name XMPF_XM, the scoring jury, and the project rating Xmpf_small_zf. I now want to calculate the total score given by the judges, but the results obtained by using the following statements are not correct, such as the project named a project, the expert to the XMPF_SMALL_ZF column values of 0, 1, 1, but the result is 8. The score is generally 6 points higher, really do not know what is wrong. Let me see it, please!
$XMPC _id= ' 4 ';/******************************************/$query 1=mssql_query ("select * from TB_XM where xm_pcid= ' $ xmpc_id ' "), while ($myrow 1=mssql_fetch_assoc ($query 1)) {echo $myrow 1[xm_name]; $xm _name = $myrow 1[' 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] '); }
Reply to discussion (solution)
Not Sufficient conditions
SELECT * from TB_XM where xm_pcid= ' $xmpc _id '
The project name is obtained by batch, and the batch and project name are not one by one corresponding
A project name can be classified into different batches
Select SUM (XMPF_SMALL_ZF) as ZF from Tb_xmpf where xmpf_xm= ' $myrow 1[xm_name] '
Get a score by project name
But the batch factor was not taken into account
Mysql_fetch_assoc