0
<?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'];
?>

Edited by pritaeas: Added markdown.

4
Contributors
4
Replies
11
Views
3 Years
Discussion Span
Last Post by diafol
0

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

0

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.

0

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'];

}

Edited by pranay.baba

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.