<?php
······
$result = mysql_query("SELECT SUM(fenshu) FROM chengji where kemu ='数学');
mysql_close($link);
?>以上是统计出成绩表中所有数学分数的和,我想让这个数字结果显示在text文本框中,哪位高手请指教text中的代码怎么写,上面不对的代码也请完善一遍

解决方案 »

  1.   

    <input type="text" name="abc" id="abc" value="<?php echo $result; ?>" />
      

  2.   

    $result = mysql_query("SELECT SUM(fenshu) FROM chengji where kemu ='数学');
    $row = mysql_fetch_array($result);<input type="text" name="abc" id="abc" value="<?php echo $row['fenshu']; ?>" />
      

  3.   

    <?php
     if($result)
     {
       if(mysql_num_rows($result)==1)
       {
        $row=mysql_fetch_array($result);
       }
     }
    <input type="text" name="abc" id="abc" value="<?php echo $row[0]; ?>" />
      

  4.   

    <?php
    $result = mysql_query("SELECT SUM(fenshu) AS fenshu FROM chengji where kemu ='数学'); 
    $row = mysql_fetch_array($result);
    ?>
    <input type="text" name="abc" id="abc" value="<?php echo $row['fenshu']; ?>" />
      

  5.   

    可以用Php调用cmd
      

  6.   

    补充一下:$result = mysql_query("SELECT SUM(fenshu) FROM chengji where kemu ='数学'); 改:$result = mysql_query("SELECT SUM(`fenshu`)as total FROM `chengji` where `kemu` ='数学'"); 
    $total 累加的结果
      

  7.   


    是可以,但一般很少调用CMD,几乎不。
      

  8.   

    用ajax 可以实现