I am trying to create an event calendar when hockey players can see when they play their games. I kinda got some problems with the code.
Code: Select all
//Connect to the DB
require_once('mysql_connect.php');
//Make the query
$query = "SELECT scheduleid, DAYOFMONTH(sdate) AS sd, steam, sarena, supdate FROM schedule";
//Run the query
$result = @mysql_query($query);
//If it ran OK, display the records
if($result) {
//Fetch and print all the records.
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){[/color]
// How many days are in the current month
$Days_In_Month = cal_days_in_month(CAL_GREGORIAN, date("m"), date("Y"));
// Gets the Current day, day with 1st 2nd etc, day name, year (2004), month,
// month name
$Current_Day = date("d");
$Current_Day_S = date("dS");
$Current_Day_Name = date("l");
$Current_Year = date("Y");
$Current_Month = date("m");
$Current_Month_Name = date("F");
// Get the offset of the first day of the month
$First_Day_Of_Month = date("w", mktime(0, 0, 0, $Current_Month, 1, $Current_Year));
// Set the day names
$Days_Array = array();
$Days_Array[] = "Sun";
$Days_Array[] = "Mon";
$Days_Array[] = "Tues";
$Days_Array[] = "Wed";
$Days_Array[] = "Thurs";
$Days_Array[] = "Fri";
$Days_Array[] = "Sat";
// For each of the Day Names, print em out
$Day_Names = "";
foreach ($Days_Array as $x => $y) {
$Day_Names .= '<th class="tableheader">' . $y . '</th>';
}
// Spacers for the offset of the first day of the month
$Cal_Weeks_Days = "";
$i = $First_Day_Of_Month + 1;
if ($First_Day_Of_Month != "0") {
$Cal_Weeks_Days .= '<td colspan="' . $First_Day_Of_Month . '"> </td>';
}
// Cal Days - The first day is 1, default with PHP is 0, so lets set it to 1
$Day_i = "1";
$ii = $i;
for ($i; $i <= ($Days_In_Month + $First_Day_Of_Month) ;$i++) {
// $i is our color variable - Alternate row colors:
if ($i % 2) {
$color = '#FFAAFF';
}
else
{
$color = '#FFFFAA';
}
// If the current day is sunday, make sure a new row gets set
if ($ii == {
$Cal_Weeks_Days .= "</tr><tr>";
$ii = 1;
}
// If the day is the current day, highlight it with a special color
if ($row['sd'] == $Day_i) {
$eventinfo = $row['steam'];
}
else
{
// Alternate row colors
$eventinfo = null;
}
// Show the days.
$Cal_Weeks_Days .= '<td><span class="bold">' . $Day_i . '</span><br>' . $eventinfo . '</td>';
// Increment the day number and the week day number (ii)
$Day_i++;
$ii++;
}
// Add end month spacers
if ((8 - $ii) >= "1") {
$Cal_Weeks_Days .= '<td colspan="' . (8 - $ii) . '"> </td>';
}
}
//Free up the ressources
mysql_free_result($result);
}
//If it did not run OK.
else {
echo '<h3>News could not be retrieved</h3>';
}
//Close Connection
mysql_close();
?>
<h1><?php echo "$Current_Month_Name $Current_Year"; ?></h1>
<table cellpadding="0" cellspacing="1" class="scheduletable" align="center">
<tr>
<?php echo "$Day_Names"; ?>
</tr>
<tr>
<?php echo "$Cal_Weeks_Days"; ?>
</tr>
<tr>
<th colspan="7">Abbreviations: AG=Atom Girls, PG=PeeWee Girls, MG=Midget Girls, BG=Bantam Girls</th>
</tr>
</table>By the way in the column "sdate" it's a date/time column. I need to display the time as well.
I need some help!!!
Burrito: Please use
Code: Select all
tags when [url=http://forums.devnetwork.net/viewtopic.php?t=21171]posting code in the forum[/url].[/size]