Get data for a next available date from mysqldatabase

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
peter162in
Forum Newbie
Posts: 12
Joined: Mon Jul 06, 2009 11:37 am

Get data for a next available date from mysqldatabase

Post by peter162in »

Get data for a next available date from mysql database if data not available for the specified date.

Data arranged in table date wise. But for some date there is no data.
any help how to proceed ahead.


include "dbconect.php";

$date=$_GET['date'];

$sql = "SELECT * FROM table1 WHERE date='$date'";


$result = mysql_query($sql) or die(mysql_error());

if ( empty($result)) {
$dif2=strtotime ( '-1 day' , strtotime ( $date ) ) ;
$date2=date ( 'Y-m-d' , $dif2 ) . "<br />\n" ;


echo"$date2". "<br />";

}

$sql = "SELECT * FROM table1 WHERE date='$date2'";


Any idea
?>
Post Reply