如何使用PHP在HTML上的mysql数据库中获取值的总和 [英] How to get sum of values in mysql database on HTML using PHP
本文介绍了如何使用PHP在HTML上的mysql数据库中获取值的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过在表格中对html表单上的值和输出进行分组来获得行的总和
我尝试了什么:
how to get the total sum of rows by grouping values and output on html form in a table
What I have tried:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbName = "satapp";
$conn = new mysqli($servername, $username, $password, $dbName);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$query = "SELECT indiname, baseline from indicators GROUP BY indiname";
$result = $conn->query($query);
?>
<!DOCTYPE html>
<title>get Records
<div style="width: 500px">
<!--<a href="one.php"<h3 align="center">get Records</h3>-->
<?php
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
?>
<?php
}
}
$conn->close();?>
<table><tbody><tr><th>Intervention Area</th><th>Target</th><th>Progress</th></tr><tr><td><?php echo $row["Interventionarea"];?></td><td><?php echo $row["target"];?></td><td><?php $number=array("progress"); echo array_sum($number);?></td></tr></tbody></table>
</div>
推荐答案
servername = localhost;
servername = "localhost";
用户名 = 根跨度>;
username = "root";
密码 = 跨度>;
password = "";
这篇关于如何使用PHP在HTML上的mysql数据库中获取值的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文