Forum Moderators: coopster
Here is the form I have
<form name="search" method="post" action="search.php">
From this date:
<input name="FromDate" type="text" id="FromDate">
To this date:
<input name="ToDate" type="text" id="ToDate">
<input type="submit" name="Submit" value="Submit">
</form>
I have a column "OrderDate" in my mySQL database. It has the format of "yyyy-mm-dd". I need to do something as
$resutls=mysql_query("select * from transaction WHERE OrderDate BETWEEN $FromDate AND $ToDate" , $link);
or
$resutls=mysql_query("select * from transaction WHERE OrderDate >= $FromDate AND OrderDate <= $ToDate" , $link);
Anybody can help me on how to do this?
Is something not working?
Your first SQL query looks ok, but use apostrophes instead. Also, access the form data using $_POST. Something like this:
$resutls=mysql_query("select * from transaction WHERE OrderDate BETWEEN '".$_POST['FromDate']."' AND '".$_POST['ToDate']."'" , $link);
dc
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in search.php on line 22
The script I wrote is:
$FromDate=$_POST['FromDate'];
$ToDate=$_POST['ToDate'];
$resutls=mysql_query("select * from transaction WHERE OrderDate BETWEEN '".$FromDate."' AND '".$ToDate."'" , $link);
while($myinfo=mysql_fetch_array($results))
{
echo $myinfo['ExamDate'];
}