Calendar
Posted: Mon Jun 12, 2006 10:25 pm
feyd | Please use
Output:
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I'm trying to create a calender, but I can not line my dates up on the same row. It list the dates on the correct day, but it puts is date in a new table row which I'm not trying to do. Here is my code listed below and the out put. What I'm I doing wrong, any suggestion?
Code:Code: Select all
<html>
<title>Test Calendar</title>
<head></head>
<body>
<table border="0" cellpadding="2" cellspacing="2" bgcolor="#ffffff">
<tr valign="top">
<td align=center>Sun</td>
<td align=center>Mon</td>
<td align=center>Tue</td>
<td align=center>Wed</td>
<td align=center>Thu</td>
<td align=center>Fri</td>
<td align=center>Sat</td>
</tr>
<?php
// set numberic representation of a month
$nmon = date("n");
// set number of days in the given month
$ndays = date("t");
// set full numeric representation of year, 4 digits
$nyear = date("Y");
echo "<tr>\n";
for ($i = 1; $i <= $ndays; $i++) { // loop the number of days in the month
for ($j = 0; $j <= 6; $j++) { // loop to find which day is the 1st on
$dno = date("w", mktime(0, 0, 0, $nmon, $i, $nyear)); // capture what day is the 1st on
if ($dno == $j) { // if
echo "<td align=center>$i</td>\n";
}
else {
echo "<td> </td>\n";
}
}
echo "</tr>\n";
}
?>
</body>
</html>Code: Select all
Sun Mon Tue Wed Thu Fri Sat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]