简体   繁体   English

使用SQL算术查询将结果显示到表

[英]Display result to table using sql arithmetic query

I want to display the result to table using this code 我想使用此代码将结果显示到表中

$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);
}

When I run the code I always have an error. 运行代码时,我总是会出错。

Ive got it now. 我已经明白了。 I used this query "SELECT round(AVG(pr1+pr2+pr3+pr4+pr5+pr6+pr7+pr8+pr9)/9,2) FROM tbl_summative_results WHERE subject_description = '".$q."'";" 我使用了以下查询:“ SELECT round(AVG(pr1 + pr2 + pr3 + pr4 + pr5 + pr6 + pr7 + pr8 + pr9)/ 9,2)FROM tbl_summative_results WHERE subject_description ='“。$ q。”“”;“

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM