我是一个绝对的新手,仍在解决问题。如果代码看起来很业余,那么请饶恕我。
我有这个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中处理,现在报告.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>";
我不知道接下来要做什么...... 它不起作用,我尝试了一些东西,但我怎样才能在特定的日期范围内回显结果。谢谢!
新编辑----
这就是新代码的样子...... Form
开始日期
结束日期
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>
-----如果我现在处理它我得到这个错误 - 解析错误:语法错误,第32行/home/simples2/public_html/test/report.php中的意外T_STRING(我在上面评论了它的起始位置) 如何申报结束日期?
谢谢和问候!
答案 0 :(得分:0)
不知道它是否是拼写错误但php应该是<?php
$_POST["dater"]=$date
这应该是
$date=$_POST["dateStart"]
此外,您还应为dateEnd添加POST
查询应该更像:
SELECT * FROM `xxxxxxx` WHERE dateColumn<=$date