0

我使用此代码从日期范围获取数据。但它只显示一行作为结果。mysql“日期”列使用“日期”作为数据类型。告诉我我做错了什么。

if(isset($_POST['from'])&& isset($_POST['to'])){
    include_once('../connection.php');
    echo $from= $_POST['from'];
      echo $to=$_POST['to'];
      $query_view="SELECT * FROM user_log where Date between '$from' and '$to'";
      $data_view=mysql_query($query_view,$connect);

.

while($row_view=mysql_fetch_array($data_view)){
    echo"
    <tr><td>".$row_view['User']."</td><td>".$row_view['Date']."</td><td>".$row_view['Time']."</td></tr>";
    }
    }
4

2 回答 2

1

我想你想要:

  echo $to=$_POST['to'];

代替

  echo $to=$_POST['from'];
于 2013-07-13T13:04:24.790 回答
0

试试这个代码

if(isset($_POST['from'])&& isset($_POST['to']))
{
     include_once('../connection.php');
     echo $from= $_POST['from'];
     echo $to=$_POST['to'];
     $query_view="SELECT * FROM user_log where `Date` between '".$from."' and '".$to."'";
     $data_view=mysql_query($query_view,$connect);
于 2013-07-13T13:04:05.207 回答