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
understanding functions and classes
Code: [Select]
class person {
var $name = "Jimmy Goe";
function get_nam
square instead of number
Hello
I do not know why but this code seems to work fine only in my xampp local insallation but n
How can I Compare two xml documents?
Hi all,
I am doing a POC for my project and I am using XE database 10g version.
login box shows up again after logging in 2nd login works
Hello,
I am having trouble on my site Lockerz.rack111.com where when you login the login box
timed header image rotation
I have a joomla site and I was trying to setup a rotating image based on timing NOT just refreshing
Splitting Attributes
SQL> SELECT I_NAME, substr(I_NAME,1,instr(I_NAME,'O')) "First part",
substr(I_NAME, IN
Echoing If Function?
A script I am using has If statements in the comments form to basically tell the form what to do. Cu
Seperate team from score
I am writing a site that does a NFL Pick 'em type application and I have a feed that gives me the sc
Extracting Long text from message class with parameters
Hi,
I would like to extract the long text from a message class. However, the long text ha
PHP FTP connect doesn't work with correct login
Hi!
i am working on this test code:
Quote<?php
$ftp_ser