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
ASP.NET 2.0 - Enter Key - Default Submit Button
Hi,One of the most annoying things in developing web pages is handling the "Enter key" for form subm
Help With editting and deleting form
Hallo !!
So look at this image :
http://img194.imageshack.us/img194/8272/snapshot5f.pn
user administration
Dear @all,
what I have to do to set the user defaults for new users. At the moment I woul
problems with search form numerical "between" sending by php
I am trying to display the results of a search, on a sql database, on a web page. I set up html &quo
PHP not creating file.
Its supposed to create a .ini file in the /scriptfiles/users/ with the name they entered into the fi
Need help making login verification cleaner...
I use the below to verify user login. I first check the cookie for the id, ip and a unique id. If it
sql error
I have been looking at this code for 20mins and can't work out what I am doing wrong. There is somet
Doubles are giving me problems
Ok so, first of all i made a double = 0.05, but when running the debugger it shows up as 0.04999. I
Warning message
I've put a website that I was doing live and I'm getting this warning message when I try to add a ne
simple script won't work. Please help
I'm new to php, and I am having trouble displaying a simple script in my web browser. My php code ex