so yeah, i am writing a script for a very simple calendar. and when it comes to showing upcoming events, i must be retarded cause i cant get it to work. here is my code…
<style type="text/css">
<!--
.month,
.np,
.weekday,
.day,
.event,
.today{
font-size:12px;
font:Verdana, Arial, Helvetica, sans-serif;
text-align: center;
width:20;
}
.today {
background-color: #EFEFEF;
color:#990000;
border:1px solid #B5B5B5;
}
.event {
background-color: #CCFFFF;
color: #003366;
border:1px solid #B5B5B5;
}
.day {
background-color: #FFFFFF;
color:#262626;
}
-->
</style>
<?php
include"_includes/db.php";
if(!isset($month)){
$month=date("m");
}
if(!isset($year)){
$year=date("Y");
}
$fom = mktime (0,0,0, $month, 1, $year);
$maxdays = date('t', $fom);
$date_info = getdate($fom);
$month = $date_info['mon'];
$month_prev = $month-1;
$month_next = $month+1;
$month_f = $date_info['month'];
$year = $date_info['year'];
$weekday = $date_info['wday'];
$day = 1;
$day_width=20;
print"<table cellpadding=\"0\" cellspacing=\'1\">
";
print"<tr>
";
print"<td class=\"np\"><a href=\"?month=$month_prev\"><!--«--></a></td>
";
print"<th class=\"month\" colspan=\"5\">$month_f<br/>$year</th>
";
print"<td class=\"np\"><a href=\"?month=$month_next\"><!--»--></a></td>
";
print"</tr>
";
print"<tr>
";
print"<td class=\"weekday\">S</td>
";
print"<td class=\"weekday\">M</td>
";
print"<td class=\"weekday\">T</td>
";
print"<td class=\"weekday\">W</td>
";
print"<td class=\"weekday\">T</td>
";
print"<td class=\"weekday\">F</td>
";
print"<td class=\"weekday\">S</td>
";
print"</tr>
";
print"<tr>
";
if($weekday > 0){print "<td colspan=\"$weekday\"> </td>
";}
$result=mysql_query("SELECT DATE_FORMAT(date,'%Y-%m-%e'),DATE_FORMAT(thrudate,'%Y-%m-%e'),event FROM dealer_events ORDER BY date");
while($row=mysql_fetch_row($result)){
while ($day <= $maxdays){
$event=$row[0];
$desc=$row[2];
$thisday="$year-$month-$day";
if($weekday == 7){
print "</tr>
<tr>
";
$weekday = 0;
}
if((date("Y-n-j")==$thisday)){
print "<td class=\"today\">$day</td>
";
}elseif($event==$thisday){
print "<td class=\"event\"><acronym title=\"$desc\">$day</acronym></td>
";
}else{
print "<td class=\"day\">$day</td>
";
}
$day++;
$weekday++;
}
}
print"</tr>
";
print"</table>
";
?>
here you can view its out come…
i know whats wrong, its the while loop where im fetching the data from the database, i just have no idea how else to get it… (as you can see form the link, only the first event in the database is displayed…) any help or direction would be more then appriciated…
thanks in advance,
~ryan