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
A Few Questions
Hi, I want to ask a few questions that I can't seem to find..
1) I'm creating a "shortcu
PHP Form to Variable.
Hi! I have written a HTML-form code in DreamWeaver CS3 (in a PHP doc) and I really need it to work s
Trouble checking SESSION cookie
I am trying to use $_SESSION cookies to verify admin privileges .
I don't understand why this is
PHP5/Zend 2.0 - Resources
PHP5 Snapshots
http://snaps.php.net/
ZEND 2.0 Feature Overview and Design (PDF File
Getting the full city list from maxminds geoip database
I am suprised I can't find any references to this.
I have maxminds geoip lite installed and i
PHP Include w/If IE Condition Statement?
I was having a problem with Internet Exploder (big surprise, right?) displaying my drop down menus i
Production Order Enterprise Service to Manufacturing Exctn Sys (MES) ???
Hello Experts,
In our current landscape SAP ECC 5.0 is integrated to MES system via PI 7.
Need help to modify php ELSE code
I'm trying to find a way to have the php code display a message if there is no inventory listed in t
php include email form with attachment
I have had no luck with finding a email form all over the Internet for various reasons. Some insecur
Problem with DB connection
Hello there! I'm new to this forum and I'm new to PHP coding also. I wrote something that doesn't ma