gpt4 book ai didi

日期范围内的php结果

转载 作者:行者123 更新时间:2023-11-30 23:13:00 24 4
gpt4 key购买 nike

我绝对是个新手,还在解决问题。如果代码看起来很业余,请饶了我吧。

我有这个 form.html

用户输入日期范围。

      form action="report.php" method="post"
FROM DATE <input type="DATE" class="textarea" name="dateStart"><br> </br>
TO DATE <input type="DATE" class="textarea" name="dateEnd">
<input type="submit" class="textarea">
</form>

这在 Report.php 中得到处理,现在 report.php 看起来像这样:

             php
$_POST["dater"]=$date;
$con=mysqli_connect("LOCALHOST","xxxxxxx","xxxxxx","xxxxx");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM `xxxxxxx`
dater);


echo "<table border='1'>
<tr>
<th>DATE</th>
<th>MBM</th>
<th>bulkTank</th>
<th>bagsAt40</th>

";

     while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['bulkTank'] . "</td>";
echo "<td>" . $row['bagsAt40'] . "</td>";
echo "</tr>";
}
echo "</table>";

我不知道下一步该做什么......它不起作用,我尝试了一些方法,但如何在特定日期范围内回显结果。谢谢!

新编辑----这就是新代码的样子……表格 开始日期
结束日期

     Report.php

<?php
$date=$_POST["dateStart"];
$con=mysqli_connect("LOCALHOST","XXXXXXX","++++++","XXXXXX");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM `WeeklyStockTake`
WHERE dateColumn=$date);


echo "<table border='1'> <!--line 32 starts here--!>
<tr>
<th>DATE</th>
<th>MBM</th>
<th>bulkTank</th>
<th>bagsAt40</th>

-----如果我现在处理它,我会得到这个错误 -Parse error: syntax error, unexpected T_STRING in/home/simples2/public_html/test/report.php on line 32 (我在上面评论过它从哪里开始)如何声明结束日期?

谢谢和问候!

最佳答案

不知道是不是拼写错误,但 php 应该是 <?php

$_POST["dater"]=$date

应该是

$date=$_POST["dateStart"]

此外,您还应该为 dateEnd 添加一个 POST

查询应该更像:

SELECT * FROM `xxxxxxx` WHERE dateColumn<=$date

关于日期范围内的php结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19127792/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com