<?php
include("db.php");

$result1 = mysql_query("SELECT DATE_FORMAT(CURDATE(), '%Y-%c-%d %H:%i')  ");
$row=mysql_fetch_array($result1);  
$from=$row['0'];
echo $from;
echo "<br>";

$result2 = mysql_query("SELECT   DATE_FORMAT(CURDATE()  - INTERVAL 2 DAY , '%Y-%c-%d %H:%i')");
$row1=mysql_fetch_array($result2);
$to=$row1['0'];
echo $row1['0'];

$result3 = mysql_query("SELECT * from pr where  date between  '$to' and  '$from' ");
$row3=mysql_fetch_array($result3);
//$to=$row3['0'];
echo $row3['0'];
echo $row3['1'];
?>

Recommended Answers

All 4 Replies

please explain what problem you are facing any error or other thing first you hav eto explain that thing to us

Do:

$query = "SELECT * from pr where  date between  '$to' and  '$from' ";
$result3 = mysql_query($query) or die(mysql_error() . '<br/>' . $query);

and paste the message here. I assume your date format is not correct.

i need to retrive rows of in between two dates.
so iam using this query.it not giving any error and not displaying result.

hear date is one coloum in my table this datatype is "date".

$result3 = mysql_query("SELECT * from pr         where  date between  '2013-11-17' and
'2013-11-21' ");
while($row3=mysql_fetch_array($result3));
{


echo $row3['name'];

}
Member Avatar for diafol

Did you do as pritaeas suggested or did you, as seems from your code, ignore him?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.