Friday 2 February 2018

PHP Tutorial : Find Upcoming Date From Database | WAMP | LAMP | phpmyadmin



Source Code :- Next_day.php
<?php
//$name=$_POST["name"];
$con=new mysqli("localhost","root","","test");
$result=$con->query("select * from dates order by date ASC");
$year=date("Y");
while($row = $result->fetch_assoc()) {
       // echo "Date:" . $row["date"]." Day :". $row["name"]."<br/>";
        if($year==  substr($row['date'], 0, 4))
        {
           
            if((int)substr($row['date'], 5, 6)==(int)date("m"))
            {
                if((int)substr($row['date'], 8, 9)>(int)date("d"))
                {
                    echo "Upcoming Date:" . $row["date"]." <br/>Upcoming Day :". $row["name"]."";
                    break;
                }
            }
            else if((int)substr($row['date'], 5, 6)>(int)date("m"))
            {
                echo "Upcoming Date:" . $row["date"]." <br/>Upcoming Day :". $row["name"]."";
                break;
            }
        }
    }
?>

No comments:

Post a Comment