我自己遇到了这个问题,这是我想出的解决方案:
<form action="" method="post" name="submit">
<input type="date" name="begin"/>
<input type="date" name="end"/>
<input type="submit" name="submit" value="Submit"/>
</form>
<?php
error_reporting(0);
$start = strtotime($_POST['begin']);
$end = strtotime($_POST['end']);
$con=mysqli_connect("localhost","user","password","dbname");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT user, SUM(1) FROM processed WHERE `date` BETWEEN FROM_UNIXTIME($start) AND FROM_UNIXTIME($end) GROUP BY first_name ;" );
echo "<table border='1' class='data'>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Total Processed</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['first_name '] . "</td>";
echo "<td>" . $row['last_name '] . "</td>";
echo "<td>" . $row['numb'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
我不知道这对您有多大帮助,但我进行了设置,以便您可以实际选择所需的日期,而不是在代码中使用硬值。