Help with PHP Calendar code...
Posted on
16th Feb 2014 07:03 pm by
admin
Hello, I'm new to this forum and I'm glad I found it.
I wrote this code for a PHP calendar as an assignment for college.
It works fine, but I also want today's day to show in another color and I can't find how to do that.
Can anyone help?
Below is the code...
Code: <html>
<head>
<div align="center"> <h1>Calendar</h1> </div>
</head>
<body BGCOLOR="lightgreen">
<blockquote>
<p>
<div align="center">
<table border="1">
<?php
if (isset($_GET['next']))
{
$month = $_GET['month'] + 1 ;
$year= $_GET['year'];
if($month > 12)
{
$month = 1;
$year++ ;
}
$cur_date = mktime(0,0,0,$month,1,$year);
}
elseif(isset($_GET['prev']))
{
$month = $_GET['month'] - 1;
$year= $_GET['year'];
if($month < 1 )
{
$month = 12;
$year-- ;
}
$cur_date=mktime(0,0,0,$month,1,$year);
}
else
{
$cur_date=mktime();
$year=date('Y',$cur_date);
$month=date('m',$cur_date);
$cur_date = mktime(0,0,0,$month,1,$year);
}
$month_name = date('F', $cur_date);
$week_days = array(Mon,Tue,Wed,Thu,Fri,Sat,Sun);
echo "<tr><td colspan="7">$month_name $year</td></tr>";
echo '<tr>';
foreach($week_days as $day)
{
echo "<td>$day</td>";
}
echo '</tr>';
$num_of_days = date('t',$cur_date);
$i = 1;
$first_day = date('D', $cur_date);
while ($i <= $num_of_days)
{
echo '<tr>';
foreach($week_days as $day)
{
echo '<td>';
if ( (($i == 1) && ($day != $first_day)) || $i > $num_of_days)
$val = '';
else
$val = $i++;
echo "$val </td>";
}
echo '</tr>';
}
?>
</table>
</div>
</blockquote>
<div align="center">
<form name="nav_form" method="get" action = '<?php echo $_SERVER['PHP_SELF'];?>' >
<input type="submit" name="prev" value="<<" >
<input type="submit" name="next" value=">>" >
<input type="hidden" name="month" value='<?php echo $month?>' >
<input type="hidden" name="year" value='<?php echo $year ?>' >
</div>
</form>
</body>
</html>
No comments posted yet
Your Answer:
Login to answer
138
10
Other forums
Suggestions for Functional module
Hello experts,
I Have done B.Sc(Mathematics) and MCA & have learnt SAP/ABAP but do n
Problem with PHP/mySQL login code
Hello,
There is an error in my login script and I can't figure out what it is...
I believe
$action = "insert"; //$action = $_GET['action'];
$action = "insert";
//$action = $_GET['action'];
why is this invalid type? I am
Confused with Loop
guys, i got confused with Looping...this is the case
I have 3 stocks, let say "Stock A&q
Hyperlink is adding an extra gap to variable
Hi, here's my problem..
I have a php generated page with a hyperlink which opens in a new win
Form errors in an array
I'm processing a form and putting the errors in an array. empty($errors) doesn't seem to do the tric
Searching keywords from array
Hello everyone, Im just wondering if someone could help me with another issue im having. Im still le
Alterar a hora do servidor
Se alguém souber, ajude-me a adicionar 6 horas, obrigado
<tr>
&
BackButton Behaviour in AJAX
I have an ASPX Page AJAX Enabled!The page has a gridView and a DDL for filtering on it. The Gridview
help with image upload code
Hello,
right now this code I have resizes images and then places them into the uploads folder