/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Number of rows for calendar

I’m building my own calendar and everything is working wonderfully expect I can’t figure out how to tell the calendar how many rows to print. Can anyone help me out with this?

Here is what I’ve got so far!

[code=php]<?php
// Collect the current date or desired date
if (isset($_GET[‘view’])){
$getDate = $_GET[‘view’];
$viewDate = explode(‘/’, $getDate);
$month = $viewDate[0];
$year = $viewDate[1];
}else{
$month = date(“m”);
$year = date(“Y”);
}

// Collect information on the current date or desired date
$date = mktime(0, 0, 0, $month, 01, $year);
$monthName = date(“F”, $date);
$totalDays = date(“t”, $date);
$startDay = date(“w”, $date);

// Find today
$today = date(“d”) . date(“m”) . date(“Y”);

// Generate previous link
$previous = $month – 1;
if ($month == 01){
$previousYear = $year – 1;
}else{
$previousYear = $year;
}
$previousDate = mktime(0, 0, 0, $previous, 01, $year);
$previousMonth = date(“F”, $previousDate);
$previousNumberProper = date(“m”, $previousDate);

// Generate next link
$next = $month + 1;
if ($month == 12){
$nextYear = $year + 1;
}else{
$nextYear = $year;
}
$nextDate = mktime(0, 0, 0, $next, 01, $year);
$nextMonth = date(“F”, $nextDate);
$nextNumberProper = date(“m”, $nextDate);

// Print calendar
$printTR = 1;
$printTD = 1;
$day = 1;

?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>Greyfish Creative</title>
<meta http-equiv=”content-type” content=”text/html; charset=iso-8859-1″/>

<link rel=”stylesheet” type=”text/css” media=”screen” href=”calendar.css”/>
</head>

<body>
<?php
echo “<table id=”calendar”>n”;
echo “<tr id=”explore”><td id=”previous” class=”exploreLink”><a href=”index.php?view=$previousNumberProper/$previousYear”>$previousMonth</a></td><td id=”month” colspan=”5″>$monthName</td><td id=”next” class=”exploreLink”><a href=”index.php?view=$nextNumberProper/$nextYear”>$nextMonth</a></td></tr>n”;
echo “<tr id=”days”><td>Sunday</td><td>Monday</td><td>Tuesday</td><td>Wednesday</td><td>Thursday</td><td>Friday</td><td>Saturday</td></tr>n”;

while ($printTD <= 35){
if ($printTR == 1){
echo “<tr class=”week”>”;
}

if ($printTD <= $startDay + $totalDays){
if ($printTD > $startDay){
echo “<td>$day</td>”;
$day++;
}else{
echo “<td>before</td>”;
}
}

if ($printTD > $startDay + $totalDays){
echo “<td>after</td>”;
}

if ($printTR == 7){
echo “</tr>n”;
$printTR = 1;
}else{
$printTR++;
}
$printTD++;
}

echo “</table>n”;
?>
</body>

</html>[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@Phill_PaffordMay 16.2008 — don't understand the question, looks good
Copy linkTweet thisAlerts:
@GreyfishauthorMay 16.2008 — I figured it out,thanks anyways!
×

Success!

Help @Greyfish spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...