Please forgive me my lousy English.
I want to get 'How many week in this month' and That number of loop of the week. But my code doesn't worked.(When i checked php value '$weekcnt' in correct number. but doesn't start loop.) Please help me, and tell me what is my problem.
<script>
//How many week in this month
var calcWeekCountInTargetYearAndMonthByDate = function(year, month, day) {
var d = new Date(year, month, day);
return Math.floor((d.getDate() - d.getDay() + 12) / 7);
}
//Get this month's last day
var calcThisMonthEndDate = function(year, month){
var dt = new Date(year, month, 0).getDate();
return dt;
}
</script>
<?php
//How many week in this month
$weekcnt = '<script type="text/javascript">document.write(calcWeekCountInTargetYearAndMonthByDate(2015, 6, calcThisMonthEndDate(2015,6)));</script>';
echo "There is ".$weekcnt." Weeks <br>";
//number of loop of the week
for($tablecnt = 0; $tablecnt < $weekcnt; $tablecnt++)
{
echo "NOW = ".$tablecnt;
//Test print
}
?>
Result(google chrome)
There is 5 Weeks