1

我是一个绝对的新手,仍在解决问题。如果代码看起来很业余,请原谅我。

我有这个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>";

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

新编辑 ---- 这就是新代码的样子... 表格 START DATE
END DATE

     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(我已经在上面评论了它的开始位置)如何声明结束日期?

谢谢并恭祝安康!

4

1 回答 1

0

不知道它是否是一个错字,但 php 应该是<?php

$_POST["dater"]=$date

这应该是

$date=$_POST["dateStart"]

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

查询应该更像:

SELECT * FROM `xxxxxxx` WHERE dateColumn<=$date
于 2013-10-01T23:49:04.750 回答