php - Searching Date From DateTime table -


i have code search date between start date

my database field this:

==============================================

id | userid | receiveddate

==============================================

1 | abc | 2013-07-10 14:07:40

2 | abc | 2013-07-15 16:27:04

3 | rty | 2013-07-10 16:27:04

4 | rty | 2013-07-16 16:07:04

5 | abc | 2013-07-25 11:07:04

examples database:

my search function this

$query = "select * visitdate id <> ''";  if(isset($datefrom) && $datefrom !=""){ $sql_datefrom= $sql_datefrom." , receiveddate='".$datefrom."'";}  if(isset($dateto) && $dateto !=""){     $sql_dateto= $sql_dateto." between receiveddate='".$dateto."'";}      $query = $query.$sql_datefrom.$sql_dateto;      while($row = mysql_fetch_array($result)){      echo $row['userid'];     } 

then samples html form:

<form name="form" type="post"> <input type="text" name="datefrom"> <input type="text" name="dateto"> <input type="submit" value="searh"> </form> 

problem is: how display whole data users base on selected date. thanks

try build query

 "select * visitdata id <> '' , receiveddate >= '" . $datefrom  . "' , receiveddate <= '" . . "' 

Comments