我想对日期在开始日期和结束日期之间的列基金进行总计
我遇到错误:
mysqli_fetch_assoc()期望参数1为mysqli_result,布尔值 在
中给出
PHP
*<?php
$connection = mysqli_connect("****", "****", "****", "****");
if (!$connection) {
die("Database connection failed: " . mysqli_connect_error());
}
$startdate = $_GET['startdate'];
$enddate = $_GET['enddate'];
$ssql="SELECT sum(funds) as total FROM bets WHERE date BETWEEN '$startdate' AND '$enddate'";
$sresult = mysqli_query($connection, $ssql);
while ($srow = mysqli_fetch_assoc($sresult))
{
echo "<tr>";
echo "<td class='text-center'>£".$srow['total'] . "</td>";
echo "</tr>";
}
mysqli_close($connection);
?>*
在相同的php脚本中进一步操作-可以100%正常工作,并显示查询所期望的数据
$startdate = $_GET['startdate'];
$enddate = $_GET['enddate'];
$q = "select * from betFigures WHERE date BETWEEN '$startdate' AND '$enddate'";
$query = mysqli_query($connection,$q);
$x = 1;
echo "<table class='table'><tr>";
echo "<th>date</th>";
echo "<th>funds</th>";
echo "<th>spent</th>";
echo "<th>return</th>";
echo "<th>profit</th>";
echo "<th>bets</th>";
echo "<th>wins</th>";
echo "<th>loss's</th>";
echo "<th>strike rate</th></tr>";
while($res = mysqli_fetch_array($query)){
$betfdate = $res['date'];
$funds = $res['funds'];
$spent = $res['spent'];
$bfreturn = $res['return'];
$profit = $res['profit'];
$bets = $res['bets'];
$wins = $res['wins'];
$loss = $res['loss'];
$strikerate = $res['strikeRate'];
echo "<tr><td><p>".date("d-m-Y",strtotime($betfdate))."</p></td>";
echo "<td><p>$funds</p></td>";
echo "<td><p>$spent</p></td>";
echo "<td><p>$bfreturn</p></td>";
echo "<td><p>$profit</p></td>";
echo "<td><p>$bets</p></td>";
echo "<td><p>$wins</p></td>";
echo "<td><p>$loss</p></td>";
echo "<td><p>$strikerate</p></td></tr>";
?>