Jump to content

Calendar Links


KYKK

Recommended Posts

I have a calendar, have days on it, and I want to create links for each day, but I do not manually add each link for everyday... so how can i create something so that day 1 will go to day 1 page, 2 will go to 2, without I adding the links to each one of them ?

Link to comment
Share on other sites

There's not like a "regular way" to do this stuff. I'm not going to waste time explaining some method that won't fit won't you're doing. Code is details. If you want some help, I need details about what you're doing. If not . . .

Link to comment
Share on other sites

Is this what you looking for? <table summary="Calendar"> <caption> November 2007 </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="October" colspan="3" id="prev"><a href="#" title="View posts for October 2007">« Oct</a></td> <td class="pad"> </td> <td abbr="December" colspan="3" id="next"><a href="3" title="View posts for October 2007">Dec »</a></td> </tr> </tfoot> <tbody> <tr> <td colspan="3" class="pad"> </td> <td>1</td> <td>2</td> <td>3</td> <td>4</td> </tr> <tr> <td>5</td> <td>6</td> <td>7</td> <td>8</td> <td>9</td> <td>10</td> <td>11</td> </tr> <tr> <td><a href="#">12</a></td> <td>13</td> <td>14</td> <td>15</td> <td>16</td> <td>17</td> <td>18</td> </tr> <tr> <td>19</td> <td>20</td> <td>21</td> <td>22</td> <td>23</td> <td id="today">24</td> <td>25</td> </tr> <tr> <td>26</td> <td>27</td> <td>28</td> <td>29</td> <td>30</td> <td class="pad" colspan="2"> </td> </tr> </tbody> </table>a html table with numbers....

Link to comment
Share on other sites

Good. Seeing that helps me a lot. Assuming you want to make more than one calendar, you're going about this very inefficiently. I suggest you let PHP build the calendar AND add the links at the same time. I simplified a few things so you can see how the main mechanism works.Also, it looked like you wanted this ISO style (the week begins on Monday) instead of USA style (week begins on Sunday) so that's the way I programmed it.

<table summary="Calendar"><?php	function build_calendar ($month, $year) {		// LOCATE FIRST DAY		$timestamp = strtotime("1 $month $year");		$startday = date('w', $timestamp);		$days = date('t', $timestamp);				// BUILD THE HEADER		$calendar = <<<EndOfHeader			<caption>		$month $year	</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>	<tbody>		<tr>EndOfHeader;						// BUILD THE BODY		$day = 0;		$date = 1;		while ($date <= $days) {			$startday--;			$calendar .= "\t\t\t<td>";			if ($startday <= 0) {				// EDIT THE LINK FORMAT IN THE NEXT LINE				$calendar .= "<a href='{$date}.html'>{$date}</a>";				$date++;			}			$calendar .= "</td>\n";			if ($day == 6 && $date < $days) {				$calendar .= "\t\t</tr>\n\t\t<tr>\n";				$day = -1;			}			$day++;		}		echo $calendar;	}	// PASS ANY MONTH AND YEAR TO CREATE ANY CALENDAR	build_calendar ("November", "2007");?>		</tr>	</tbody></table>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...