How do I use PHP to save data from a database to be read in a re-variable?
Use echo $myrow 1[xm_name]; You can export the project name, use Echo $myrow 2[ZF]; You can get the total score of the project, but how do you save it in a variable in PHP? $XM _name= $myrow 1[xm_name]; $xm_zf= $myrow 2[ZF]; the variable echo in the two sentences has no result.
$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];
$XM _zf= $myrow 2[ZF];
}
Share to:
------Solution--------------------
$XM _name = $myrow 1["Xm_name";
$query 3=mssql_query ("Update tb_xm set xm_zf= ' $myrow 2[zf] ' where xm_name= ' $xm _name '");
------Solution--------------------
Your ending semicolon is full-width, and you can change it to half-width.
$query 3=mssql_query ("Update tb_xm set xm_zf= ' $myrow 2[zf] ' where xm_name= ' $myrow 1[xm_name] ');