mohamad mohamad mohamad mohamad - 4 months ago 7
MySQL Question

how to print all date for a month or more

i want to print all date from today to specific day this specific day will be taken from database

$sql=mysqli_query($conn,"select * from tbl_activities where db_id='$id'")or die(mysqli_error($conn));
$row=mysqli_fetch_array($sql);
$day=$row['db_day'];


this code give me number of date example 10 days
i want to print date from today to 13 days

for($i=1;$i<=$day;$i++){

}


output will be like this

Thursday 21st of July 2016
Friday 22st of July 2016
23st of July 2016
24st of July 2016
25st of July 2016
26st of July 2016
27st of July 2016
28st of July 2016
29st of July 2016
30st of July 2016
31st of July 2016
1st of August 2016

Answer

try my edited code.

$day=$row['db_day'];

$start_day = strtotime(date("Y-m-d"));
$end_day = $start_day + 86400 * $day;

    while($end_day >= $start_day){
            echo date("j F, Y",$start_day)."\r\n";
            $start_day = $start_day + 86400;
    }