Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 显示表格单元格的平均值和总和_Php_Javascript_Jquery - Fatal编程技术网

Php 显示表格单元格的平均值和总和

Php 显示表格单元格的平均值和总和,php,javascript,jquery,Php,Javascript,Jquery,我有一张测验结果的表格,表格里有一个分数单元格 示例(单元格等级在while循环中,数字在使用if检查其他单元格后显示): 身份证件 问题: 答复 正确答案 等级 1. 问:怎么啦 布拉布拉回答 正确回答 5(此单元格包含每个问题的分数) 2. 问题2:怎么说 布拉布拉-布拉回答2 正确答案2 8(此单元格包含每个问题的分数) 等 //在这个单元格中,我想显示td等级的平均值 平均的 非常感谢 看这篇图坦卡蒙的文章,你可能在上面的第5页中提到了你想要的东西,即“5)从特定列的td中找到所有

我有一张测验结果的表格,表格里有一个分数单元格

示例(单元格等级在while循环中,数字在使用if检查其他单元格后显示):


身份证件
问题:
答复
正确答案
等级
1.
问:怎么啦
布拉布拉回答
正确回答
5(此单元格包含每个问题的分数)
2.
问题2:怎么说
布拉布拉-布拉回答2
正确答案2
8(此单元格包含每个问题的分数)

//在这个单元格中,我想显示td等级的平均值
平均的
非常感谢

看这篇图坦卡蒙的文章,你可能在上面的第5页中提到了你想要的东西,即“5)从特定列的td中找到所有值”


问题还不清楚。您的html结构是什么?您尝试获取的单元格数据是什么javascript代码?我在一个表单元格中有一些数字,我想在另外两个单元格中显示这些数字的平均值和计数。我是新来的,我不知道如何用javascript实现这一点。。例如,在一个单元格中显示等级的名称单元格等级的数量请编辑问题并发布实际的html,而不仅仅是描述。你说这些数字不是来自数据库,那么你为什么在这里显示mysql查询。最好删除它,只放相关信息。好的,非常感谢。我想得到数值,并用一些函数来显示平均值和计数。。我有点困惑,因为我是新手一旦你得到所有的值并将它们与+(确保你将变量包装在“parseInt”中),我想我不必向你解释如何计算加法和平均值,是吗?我是javascript-jqeury新手,我需要所有方面的帮助……)我正在谷歌上搜索如何做这也许能帮我你能帮我改变这个页面的代码:我的案件?所有的数字都是td:grade,我想在这个页面的输入框中显示平均值
    <table border="1">
      <tbody>
        <tr>
          <th> id </th>
          <th> question </th>
          <th> answer </th>
          <th> correct answer </th>
          <th> grade </th>


        </tr>

        <tr>

          <td> 1 </td>
          <td> question how bla bla bla</td>
          <td> bla bla answer</td>
          <td> correct answer</td>
          <td> 5 (this cell has the grade of each question)</td>
        </tr>
        <tr>

          <td> 2 </td>
          <td> question2 how bla bla bla</td>
          <td> bla bla answer2</td>
          <td> correct answer2</td>
          <td> 8 (this cell has the grade of each question)</td>
        </tr>
// in this cell i want to show me the average from td grade

<td colspan="4" align="center">average</td>
  <td><input type="text" readonly="readonly" name="Avg" /></td>      


      </tbody>
    </table>
$(".grid tr").each(function(i){
   colValues[i] = $('tr:nth-child('+(i+1)+')>td:nth-child(1)').html();
});