php分页之后求某一字段整个字段的总和

csdnczz csdnczz 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
各位亲,我现在做一个while循环的列表,现在从网上找到了一个方法,但是只能求出分页后这一页的和,而我想求这个字段所有的和,怎么求呢?
按搜索条件

下图就是求出来之后本页的和


下面就是我的部分php代码

echo "<center>" ;
echo "<form action ='../huwai/sou.php?action=del' method='POST' onSubmit='return confirm(\'你确定要删除这些纪录吗?\')'>" ;
echo "<table cellspacing='0' cellpadding='2' border='1' bordercolor='#66FF66' width='1400px'>" ;
echo "<tr bgcolor='#FFFFCC' align='center' height='20px'>" ;
echo "<th width='50px'><strong>ID号</strong></th>" ;
echo "<th><strong>日期</strong></th>" ;
echo "<th width='50px'><strong>编号</strong></th>" ;
echo "<th width='50px'><strong>县区</strong></th>" ;
echo "<th width='400px'><strong>具体地址</strong></th>" ;
echo "<th width='50px'><strong>科室</strong></th>" ;
echo "<th width='50px'><strong>姓名</strong></th>" ;
echo "<th width='60px'><strong>联系电话</strong></th>" ;
echo "<th width='30px'><strong>油</strong></th>" ;
echo "<th width='30px'><strong>米</strong></th>" ;
echo "<th width='30px'><strong>围裙</strong></th>" ;
echo "<th width='30px'><strong>现金</strong></th>" ;
echo "<th width='50px'><strong>皮革抽纸盒</strong></th>" ;
echo "<th width='50px'><strong>水宜生杯子</strong></th>" ;
echo "<th width='50px'><strong>三件套水杯</strong></th>" ;
echo "<th width='30px'><strong>高</strong></th>" ;
echo "<th width='30px'><strong>长</strong></th>" ;
echo "<th width='30px'><strong>面积</strong></th>" ;
echo "<th width='30px'><strong>安装结果</strong></th>" ;
echo "<th width='300px'><strong>备注</strong></th>" ;
echo "<th width='20px'><strong>结账状态</strong></th>" ;
echo "<th colspan='3' align='center'></th>" ;
echo "</tr>" ;

$num=8;
$sql1="select * from place {$where}";
$result1=mysql_query($sql1);
$total=mysql_num_rows($result1);
$page=new Page($total,$num,$args);
$sql="select id,time,number,xianqu,address,keshi,name,tel,you,mi,weiqun,money,pgczh,beizi,sjtsb,high,width,area,azjg,bz,jzzt from place {$where} order by `id` DESC {$page->limit}";
$result=mysql_query($sql);
while(list($id,$time,$number,$xianqu,$address,$keshi,$name,$tel,$you,$mi,$weiqun,$money,$pgczh,$beizi,$sjtsb,$high,$width,$area,$azjg,$bz,$jzzt)=mysql_fetch_row($result)){
echo "<tr>";
echo "<td>$id</td>";
echo "<td>$time</td>";
echo "<td class='number'>$number</td>";
echo "<td>$xianqu</td>";
echo "<td>$address</td>";
echo "<td>$keshi</td>";
echo "<td>$name</td>";
echo "<td>$tel</td>";
echo "<td>$you</td>";
echo "<td>$mi</td>";
echo "<td>$weiqun</td>";
echo "<td>$money</td>";
echo "<td>$pgczh</td>";
echo "<td>$beizi</td>";
echo "<td>$sjtsb</td>";
echo "<td>$high</td>";
echo "<td>$width</td>";
echo "<td>$area</td>";
echo "<td>$azjg</td>";
echo "<td>$bz</td>";
echo "<td>$jzzt</td>";
echo "<td><a href='../huwai/huwaimod.php?action=mod&id=$id'>修改</a></td>";
echo "<td><a href='../huwai/sou.php?action=del&id=$id' onclick='return confirm('确定要删除?')'>删除</a></td>";
echo "<td><input type='checkbox' name='id[ ]' value ='$id' ></td>";
echo "</tr>";
$totalarea += $area;
}

echo "<tr><td colspan='21' align='center'><span class='fenye'><ul class='fr'> {$page->fpage(array(1,8,2,3,4,5,6,7,0))}</ul></span></td><td colspan='3' align='center'><input type='submit' name='dosubmit' value='删除'/></td></tr>";
echo "<tr><td colspan='24' align='center'>总面积<本页合计>: ".$totalarea." 平方米(按搜索条件计算)</td></tr>";
echo "</table>";
echo "</form>";
echo "</center>";


我现在呢?就是想求出搜索出来之后,$area 这个字段所有相加的和!
有高手帮忙分享解决办法吧,谢谢!
...全文

相关推荐

php中单个数据库字段多列显示(单字段分页、横向输出)

主要介绍了php中单个数据库字段多列显示、分行分列显示技巧,也可称为单字段分页、横向输出,需要的朋友可以参考下

weixin_38625048

php计算多维数组中所有值总和的方法

本文实例讲述了php计算多维数组中所有值总和的方法。分享给大家供大家参考。具体实现方法如下: php 内置函数 array_sum() 函数返回数组中所有值的总和,只能返回一维数组的总和; 计算多维数组所有值的和就要自定义函数了; function get_sum($array) { $num = 0; foreach($array as $k => $v) { if(is_array($v)) { $num += get_sum($v); } } return $num + array_sum($array); } get_sum(

weixin_38504417

PHP分页显示

&lt;?php /* * 你只需要 设置 每页显示多少数据, 以及array中的数据个数就行了 * 编码:Gohomewithme */ $eachNum=4;//每页显示的数量 $nowPage=$_GET['page'];//当前页 $p=0; $arrayData=array( array("1","15","120"), array("2","16","110"), array("3","17","115"), array("4","16","110"), array("5","17","115"), array("6","17","115"), array("7","16","110"), array("8","17","115"), array("9","17","115"), array("10","16","110"), array("11","17","115"), ); ##分页处理数据算法 /*=============================================*/ $arrayNum=count($arrayData); if($arrayNum%$eachNum>0?true:false) {##大于当前页数 $sumPage=ceil(count($arrayData)/$eachNum);//总页数 }else { $sumPage=floor(count($arrayData)/$eachNum);//总页数 } $p=($nowPage-1)*$eachNum; //按页数,数据的偏移值 ##最大页数据界限处理 if($arrayNum-(($nowPage-1)*$eachNum)<$eachNum) { $eachNum=$arrayNum-(($nowPage-1)*$eachNum); } echo "总页数:".$sumPage; echo "当前页:".$nowPage; ?&gt; &lt;!--设置数据循环输出--&gt; &lt;?php for ($i=0; $i < $eachNum; $i++) { echo "姓名:".$arrayData[$i+$p][0]." 年龄:".$arrayData[$i+$p][1]." 成绩:".$arrayData[$i+$p][2]." "; } ?&gt; &lt;!--设置页数循环输出--&gt; &lt;?php for ($i=0; $i < $sumPage ; $i++) { echo "第".($i+1)."页 "; } ?&gt;

qq_38126337

PHP实现数据分页显示的简单实例

下面小编就为大家带来一篇PHP实现数据分页显示的简单实例。小编觉得挺不错的,现在就分享给大家,也给的大家做个参考。一起跟随小编过来看看吧

weixin_38693720

Dreamweaver+PHP数字分页插件

使用DreamweaverCS4 PHP数字分页插件轻松实现数字分页

tangshiyyyyy
评论 9
收藏 已收藏
分享
返回顶部
csdnczz
基础编程 21,889 成员 140,329 内容