Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

JackT06

macrumors 6502
Original poster
Jul 24, 2009
293
0
Does anyone know how to code a calendar? (i want the number to move along so people know what date it is)
I have got on which came with a template but it doesnt change the day over for me which is a pain.
Code:
<h2>Calendar</h2>
					<div id="calendar_wrap">
						<table summary="Calendar">
							<caption>
							August 2009
							</caption>
							<thead>
								<tr>
									<th abbr="Monday" scope="col" title="Monday">M</th>
									<th abbr="Tuesday" scope="col" title="Tuesday">T</th>
									<th abbr="Wednesday" scope="col" title="Wednesday">W</th>
									<th abbr="Thursday" scope="col" title="Thursday">T</th>
									<th abbr="Friday" scope="col" title="Friday">F</th>
									<th abbr="Saturday" scope="col" title="Saturday">S</th>
									<th abbr="Sunday" scope="col" title="Sunday">S</th>
								</tr>
							</thead>
							<tfoot>
								<tr>
									<td abbr="July" colspan="3" id="prev"><a href="#" title="View posts for July 2009">« July</a></td>
									<td class="pad"> </td>
									<td colspan="3" id="next"> </td>
								</tr>
							</tfoot>
							<tbody>
								<tr>
									<td>1</td>
									<td>2</td>
									<td>3</td>
									<td>4</td>
									<td>5</td>
									<tdid="today">6</td>
									<td>7</td>
								</tr>
								<tr>
									<td>8</td>
									<td>9</td>
									<td>10</td>
									<td>11</td>
									<td>12</td>
									<td>13</td>
									<td>14</td>
								</tr>
								<tr>
									<td>15</td>
									<td>16</td>
									<td>17</td>
									<td>18</td>
									<td>19</td>
									<td>20</td>
									<td>21</td>
								</tr>
								<tr>
									<td>22</td>
									<td>23</td>
									<td>24</td>
									<td>25</td>
									<td>26</td>
									<td>27</td>
									<td>28</td>
								</tr>
								<tr>
									<td>29</td>
									<td>30</td>
									<td>31</td>
									<td class="pad" colspan="4"> </td>
								</tr>
							</tbody>
						</table>
					</div>

Here is a picture of what it looks like :
JackT06
 
You are using pure html, which is a static markup language.
You will need a scripting language to dynamically update your page every time someone accesses it.

If your looking at serverside language (the server decides the time and date) you could use the PHP date() function. Problem with this is that if you have users from different time zones, they will only see the current time of where your server is located. There are ways around this, however.

Or you could use a client sided language, such as Javascript, which also has a date function, similiar to the php one. This is handy as it uses the browsers date and time, where ever it is set. Of course, if the user has messed up their own clock, this also might not be reliable.
 
You're not linking anything. Say you've got your nice *.htm web page, which does not include this calendar. You simply insert the code for the calendar you want (the one which also highlights the date is * ), and then save the *.htm page (say index.htm) to *.php (say index.php). Upload the new file to the web server (say you're using MAMP locally: /Applications/MAMP/htdocs), AND run the page in your browser (say you're using MAMP locally: http://localhost:8888/index.php).


*
Code:
<?php

$time = time();

$today = date('j',$time);

$days = array($today=>array(NULL,NULL,'<span style="color: red; font-weight: bold; font-size: larger; text-decoration: blink;">'.$today.'</span>'));

echo generate_calendar(date('Y', $time), date('n', $time), $days);

?>
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.