I am a beginner learning PHP and I am trying to make a basic calendar with PHP. Simpele kalender is how it has to look. It has to be with if and/or loops. This is what I have so far:
<?php
$month_start = 'Tue';
$number_days = 28;
// number of rows
$number_rows = $number_days / 7;
if ($number_days % 7 != 0) {
// number of days
$number_rows = ($number_days / 7) + 1;
}
?>
<table>
<tr>
<th>Mon</th>
<th>Tue</th>
<th>Wed</th>
<th>Thu</th>
<th>Fri</th>
<th>Sat</th>
<th>Sun</th>
</tr>
<?php
for($y = 1; $y <= $number_rows;$y++){
echo "<tr>";
for($i = 1; $i <= $number_days; $i++){
if($i % 7 != 0){
echo "<td>". $i . "</td>";
}
else{
echo "<td>". $i . "</td>";
break;
}
}
echo "</tr>";
}
?>
</table>
<style>
table, th, td {
border: 1px solid black;
text-align: center;
}
</style>
How do I start on Thursday (beginning of the month) and how can I get the days 1 to 28 in the columns? I made another calendar but that wasn't correct. According to the feedback I got on it, I don't need to use gmdate, cal_days_in_month and mktime. Anyone that can help me go into the right direction?
Aucun commentaire:
Enregistrer un commentaire