【问题标题】:Display result to table using sql arithmetic query使用 sql 算术查询将结果显示到表中
【发布时间】:2018-07-18 00:38:13
【问题描述】:

我想使用此代码将结果显示到表格中

$q = $_GET['q'];
mysqli_select_db($con,"ofes");
$sql="SELECT * FROM tbl_summative_results WHERE subject_description = '".$q."'";
$result = mysqli_query($con,$sql);

$sql1="SELECT (round(AVG(pr1+pr2+pr3+pr4+pr5+pr6+pr7+pr8+pr9)/9,2)) FROM tbl_summative_results WHERE subject_description = '".$q."'";
$results = mysqli_query($con,$sql1);
while($row = mysqli_fetch_array($results)) {
    echo "<tr>";
    echo "<td style='background-color:#e9efc4;color:black;font-weight:bold'>" . $row['(round(AVG(pr1+pr2+pr3+pr4+pr5+pr6+pr7+pr8+pr9)/9,2))'] . "</td>";
    echo "</tr>";
     mysqli_close($con);
}

当我运行代码时,我总是出错。

【问题讨论】:

  • 而错误是......?

标签: php sql arithmetic-expressions


【解决方案1】:

我现在明白了。我使用了这个查询 "SELECT round(AVG(pr1+pr2+pr3+pr4+pr5+pr6+pr7+pr8+pr9)/9,2) FROM tbl_summative_results WHERE subject_description = '".$q."'";"

【讨论】:

  • 我只删除查询中圆旁边的括号
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-04
  • 2010-10-15
  • 1970-01-01
  • 2018-01-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多