Help: Urgent! How to read the total score calculated in the data table and write it into another data table? I set a score table tb_xmpf, which contains the project name xmpf_xm, the judge name xmpf_user, and the score xmpf_small_zf given by the judges. now I want to calculate the total score and average score of each project, write the xm_zf and xm_avg columns in the project table tb_xm, and follow the xm_zf output table to get started with PHP. this complicated database call is urgent! How to read the total score calculated in the data table and write it into another data table?
I set a score table tb_xmpf, which contains the project name xmpf_xm, the judge name xmpf_user, and the score xmpf_small_zf given by the judges. now I want to calculate the total score and average score of each project, write the xm_zf and xm_avg columns in the project table tb_xm, and follow the xm_zf output table to get started with PHP. this complicated database call is not very useful. please help me think about it!
Share:
------ Solution --------------------
Connect to the database, and the output by table is also very simple.
$ Query = "select xmpf_xm, sum (xmpf_small_zf) zf, avg (xmpf_small_zf) avg from tb_xmpf group by xmpf_xm"; // query the average score of the total score.
$ Result = mysql_query ($ query );
While ($ row = mysql_fetch_array ($ result )){
$ SQL = "insert into tb_xm (xmpf_xm, xm_zf, xm_avg) values ($ row ['xmpf _ xm '], $ row ['zf'], $ row ['avg']) "; // average score of the total insertion score
Mysql_query ($ SQL );
}