+ 1
help php
Hello everybody! I am learning PHP and I have created a calendar as per the desired one. But I have an error on line 25 because the $ week array does not have '6'. I can not adjust it. tnks https://code.sololearn.com/w5l9y45YXaDe/?ref=app
4 Answers
+ 2
Use CSS for styling the table columns. Put this on top of document before <h1>
<style>
td {text-align:center;}
td.weekend {color:red;font-weight:bold;}
td.today {color:blue;font-weight:bold;}
</style>
Here I fixed the "line" function, this will create an empty column when a certain array element isn't set.
function line($week)
{
echo '<tr>';
$today = date('d');
for ($i = 0; $i <= 6; $i++){
if(!isset($week[$i])){
echo '<td> </td>';
continue;
}
if ($week[$i] == $today){
echo "<td class='today'>$week[$i]</td>";
}
else if ($i == 0 or $i == 6){
echo "<td class='weekend'>$week[$i]</td>";
}
else{
echo "<td>$week[$i]</td>";
}
}
echo '</tr>';
}
+ 1
Ipang I already checked and it is ok. Later I will study the points to learn. thank you so much!
+ 1
You're most welcome Luiz Felipe Gonçalves : )
0
basic problem