How can I use PHP to save the data read from the database and then store the data in the variable? Echo $ myrow1 [xm_name]; can be used to output the project name. echo $ myrow2 [zf] can be used to obtain the total project score. but how can I save it in a variable in php? $ Xm_name = $ myrow1 [xm_name]; and $ xm_zf = $ myrow2 [zf]; no result is returned after the variable echo.
$ Query1 = mssql_query ("select * from tb_xm where xm_pcid = '$ xmpc_id'"); while ($ myrow1 = mssql_fetch_assoc ($ query1) {echo $ myrow1 [xm_name]; $ xm_name = $ 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]; $ xm_zf = $ myrow2 [zf];}
Reply to discussion (solution)
Echo $ myrow1 ["xm_name"] try it. the array field name needs to be printed.
How can I save $ myrow1 ["xm_name"] to $ xm_name?
What's wrong with that?
Error message: Parse error: syntax error, unexpected T_STRING in C: \ AppServ \ www \ online_pf \ admin \ jgcx_zt_ OK .php on line 14
Echo $ xm_name; no response.
In your example, you can directly echo $ myrow1 [xm_name]; No. What are the variables used?
Because I want to save the data to a variable and write a data update statement.
$query3=mssql_query("update tb_xm set xm_zf='$myrow2[zf]' where xm_name='$myrow1[xm_name]'");
The system will report an error saying Parse error: syntax error, unexpected T_STRING in C: \ AppServ \ www \ online_pf \ admin \ jgcx_zt_ OK .php
$ Xm_name = $ myrow1 ["xm_name"];
$ Query3 = mssql_query ("update tb_xm set xm_zf = '$ myrow2 [zf] 'Where xm_name =' $ xm_name '");
Your semicolon ends with a full width. you can change it to a half width.
$query3=mssql_query("update tb_xm set xm_zf='$myrow2[zf]' where xm_name='$myrow1[xm_name]'");
The method on the eighth floor still reports an error... Parse error: syntax error, unexpected T_STRING in C: \ AppServ \ www \ online_pf \ admin \ jgcx_zt_ OK .php on line 15
Thank you! It is a semicolon problem. The input method is mixed! Thanks again for your enthusiastic help!