当前位置:Gxlcms > PHP教程 > 急急急!在线求助!

急急急!在线求助!

时间:2021-07-01 10:21:17 帮助过:4人阅读

有这么个需求。根据时间,来汇总各店相关数据。数据库里的数据,是一天传送两次。需要做一个累加

最终的效果表是下图显示



前面是上图列名,后者是数据库列对应名

网费收入==网费收入
会员收入==会员收入
商品收入==商品收入
点卡收入==点卡收入
合计==临时卡消费总额
网费单机==(网费收入+会员收入)/dmmc(表)里的对应店名机器数量列。
商品单机==商品收入/dmmc(表)里的对应店名机器数量列。
点卡单机==点卡收入/dmmc(表)里的对应店名机器数量列。
合计就是对应列相加
日均就是对应列相加之后/天数

以其中一个店面数据库表数据为例。下图



dmmc表截图




求代码!!


回复讨论(解决方案)

第二张图重新上传下。 以11.1号数据为准就可以

图片看不到,每日汇总的话可以用linux的定时任务和php命令行传递参数,总和不是select sum(字段)就行了么?

图片看不到,每日汇总的话可以用linux的定时任务和php命令行传递参数,总和不是select sum(字段)就行了么?

你好 能不能加您qq 请教你几个问题

$result=mysql_query("SELECT 日期,网费收入,会员收入,商品收入,点卡收入,网费收入+会员收入+商品收入+点卡收入 AS 合计 FROM ".$data." ",$link);

在sql中能把 每行前列的数读取出来,第五列算个求合,在mysql查询器能查出来,但是网页上却直接没有数据。如果去掉求这四列的值,就能出来 。。。 真郁闷了

你网页上取数据的时候取了合计字段了吗?还是只有前面5个字段?

店面营业查询结果\n";echo"\n";while($field=mysql_fetch_field($result)){   echo"".$field->name."\n"; 	 $str= $str.$field->name.",";	 	  }    //生成新的查询字段  $length=strlen($str);  $sumstr=substr($str, 0, $length-1);  echo $sumstr;  echo "\n"; mysql_free_result($result);$result=mysql_query("SELECT $sumstr FROM $data where 日期 between '$top' and '$end'" ,$link); while($row = mysql_fetch_row($result)) { 	    echo "\n";   for($i=0;$i".$row[$i]."";   }   echo "\n";}echo "\n";mysql_free_result($result);mysql_close($link);?>

你网页上取数据的时候取了合计字段了吗?还是只有前面5个字段?

我把代码贴出来了。我放到查询器的时候 能查出。

我在代码里,如果不做四列的求和。也能出中间四列分别的数,并且打印在网页表格里。问题是我一加上这四个数,就一个数据都没有了。所以我贴上代码了

你前四列??都已?查出各列的和了,在WEB?面上?示的?候,?什?不直接把?四列的值相加然後?示

都是中文字段,,,,?

while($field=mysql_fetch_field($result)){     echo"".$field->name."\n";      $str= $str.$field->name.",";       }//用mysql_fetch_row()试试 打印$field看看有没有数据

都是中文字段,,,,?

while($field=mysql_fetch_field($result)){     echo"".$field->name."\n";      $str= $str.$field->name.",";       }//用mysql_fetch_row()试试 打印$field看看有没有数据


直接页面都不出来了。

你这个看的头疼...
给个思路给你...先查数据变数组
再依据你的表格遍历数组做运算...

select("bp_testloglist", "testEndtime", "order by testEndtime desc limit 0,1");if ($row = $db->fetch_array($query)) {    $lastUpdateint = $row['0'] + 54000;}unset($query);unset($row);$lastUpdatedayint = strtotime(date("Y-m-d",$lastUpdateint)); //依据dell时间换成当天的开始时间int//依据测试记录最后时间变成abc时间$queryDateint = $lastUpdatedayint - 6* 24 * 60 * 60-54000;//获取最后2天的测试时间$queryDateint2 = $lastUpdatedayint - 24 * 60 * 60- 54000;$querDateabc2int = $queryDateint2+54000;//获得测试工站的Performance$query = $db->select("bp_testloglist", "testStation,testResult, testEndtime", "where testEndtime>=$queryDateint and testDatabase=0");while ($row = $db->fetch_array($query)) {    $stationSummary[dellToabcdayint($row['2'])][$row['0']][$row['1']] = $stationSummary[dellToabcdayint($row['2'])][$row['0']][$row['1']] + 1;}unset($query);unset($row);$m_Testhate = $m_Testhate + 24 * 60 * 60;//获取测试工站名称$query = $db->query("select a.testerFullname,a.testerID,a.testerType,b.stationNamelite,a.testerName,INET_NTOA(a.testerIP) from bp_tester as a left join bp_teststation as b on a.testerType = b. stationID where a.testerShow=1 order by a.testerType, testerFullname asc");while ($row = $db->fetch_array($query)) {    $testType[$row['2']] = $row['3'];    $testerHost[$row['1']] = array('testerHost' => $row[4], 'testerIP' => $row['5'], 'testerStation' => $row['3']);    $testerName[$row['1']] = $row['0'];    $i++;}unset($query);unset($row);$currentTime = date("Y-m-d H:i:s");include_once './include/system.top.php';include_once './include/system.menu.php';?>
  • TESTER
[ Test Station Performance ]_UPDATE: [ ]
" . date("Y-m-d", $a) . "
" . date("l", $a) . ""; $i++; } unset($a); ?> $value1) { $testerID = $key; ?> 0 ? @$totalPass[$value] : @$totalPass[$value] = 0; @$totalFail[$value] > 0 ? @$totalFail[$value] : @$totalFail[$value] = 0; @$totalAbort[$value] > 0 ? @$totalAbort[$value] : @$totalAbort[$value] = 0; @$totalTotal[$value] > 0 ? @$totalTotal[$value] : @$totalTotal[$value] = 0; if (arrayValue($stationSummary, $value)) { if (arrayValue($stationSummary[$value], $testerID)) { $tPass = (int) arrayValue($stationSummary[$value][$testerID], '3'); $tFail = (int) arrayValue($stationSummary[$value][$testerID], '1'); $tAbort = (int) arrayValue($stationSummary[$value][$testerID], '2'); $tTotal = $tPass + $tFail + $tAbort; $totalPass[$value] = $totalPass[$value] + $tPass; $totalFail[$value] = $totalFail[$value] + $tFail; $totalAbort[$value] = $totalAbort[$value] + $tAbort; $totalTotal[$value] = $totalTotal[$value] + $tTotal; } else { $tPass = 0; $tFail = 0; $tAbort = 0; $tTotal = $tPass + $tFail + $tAbort; $totalPass[$value] = $totalPass[$value] + $tPass; $totalFail[$value] = $totalFail[$value] + $tFail; $totalAbort[$value] = $totalAbort[$value] + $tAbort; $totalTotal[$value] = $totalTotal[$value] + $tTotal; } } else { $tPass = 0; $tFail = 0; $tAbort = 0; $tTotal = $tPass + $tFail + $tAbort; $totalPass[$value] = $totalPass[$value] + $tPass; $totalFail[$value] = $totalFail[$value] + $tFail; $totalAbort[$value] = $totalAbort[$value] + $tAbort; $totalTotal[$value] = $totalTotal[$value] + $tTotal; } if ($tTotal <> 0) { echo ""; } else { echo ""; } if ($tPass <> 0) { echo ""; } else { echo ""; } if ($tFail <> 0) { echo ""; } else { echo ""; } if ($tAbort <> 0) { echo ""; } else { echo ""; } } ?> 0) { echo ""; } else { echo ""; } if ($totalPass[$value] <> 0) { echo ""; } else { echo ""; } if ($totalFail[$value] <> 0) { echo ""; } if ($totalAbort[$value] <> 0) { echo ""; } else { echo ""; } } $totalTotal = NULL; $totalPass = NULL; $totalFail = NULL; $totalAbort = NULL; ?>
Tester / Date
T P F A
HOST NAME: " . $value1['testerHost']; ?>" > $tTotal$tPass$tFail$tAbort
Total $totalTotal[$value]$totalPass[$value]$totalFail[$value]"; } else { echo "$totalAbort[$value]


算出来就是这个样子

人气教程排行