Jump to content


Photo

calendar


  • Please log in to reply
10 replies to this topic

#1 chriscloyd

chriscloyd
  • Members
  • PipPipPip
  • Advanced Member
  • 489 posts
  • LocationArizona

Posted 31 March 2006 - 01:04 AM

im trying to create a calendar where it shows a calendar on this page cloydfamily.com/index.php?module=calendar and then an admin page where i can enter an event on a specific date how could i go about doing this and i could help u guys with free webhosting if u guys help me
44 bugs in my java code
44 bugs in my java code
Fix 1 bug, and complie again
122 bugs in my java code

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 31 March 2006 - 01:18 AM

How are you planning on storing the events, flat file or database?

It looks as though your "next" and "previous" month links also need to include "&module=calendar" in the query string
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 chriscloyd

chriscloyd
  • Members
  • PipPipPip
  • Advanced Member
  • 489 posts
  • LocationArizona

Posted 31 March 2006 - 01:19 AM

no that calendar that my friend did i kinda want my own do u knwo how to do calendars? i know how to store info in databases i just need some help on creating the idea of how to make it work
44 bugs in my java code
44 bugs in my java code
Fix 1 bug, and complie again
122 bugs in my java code

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 31 March 2006 - 08:31 PM

Yes, I know how to do calendars.

But then it would be I did instead of one your friend did - what's the difference?

Anyway, I take it the answer is database and not flat file.

You need to create an input form for the data you want to store and a table to store the data.

Something like

Event table
---------------
eventID INT (PK)
eventdate DATE
eventdesc varchar(255)
eventtype INT (FK)

Event type
----------------
eventtype INT (PK)
typedesc varchar(50)

Use event type table to crete a dropdown menu.

Create CSS styles for types of event so they display as different colors in the calendar (birthdays, anniversaries etc)

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#5 chriscloyd

chriscloyd
  • Members
  • PipPipPip
  • Advanced Member
  • 489 posts
  • LocationArizona

Posted 31 March 2006 - 11:09 PM

ya but how would i make the calendar he deleted it
44 bugs in my java code
44 bugs in my java code
Fix 1 bug, and complie again
122 bugs in my java code

#6 chriscloyd

chriscloyd
  • Members
  • PipPipPip
  • Advanced Member
  • 489 posts
  • LocationArizona

Posted 31 March 2006 - 11:28 PM

this is my code now how do i make it so when i enter information into my sqldatabase it will underline the day number and make it a link?

// 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[] = "Sunday"; 
$Days_Array[] = "Monday"; 
$Days_Array[] = "Tuesday"; 
$Days_Array[] = "Wednesday"; 
$Days_Array[] = "Thursday"; 
$Days_Array[] = "Friday"; 
$Days_Array[] = "Saturday"; 

// For each of the Day Names, print em out 
$Day_Names = ""; 
foreach ($Days_Array as $x => $y) { 
    $Day_Names .= '<td align="center" bgcolor="#ADADAD" width="14.28%">' . $y . '</td>'; 
} 

// 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 = '#0000FF'; 
    } 
    else 
    { 
        $color = '#0000FF'; 
    } 

    // If the current day is sunday, make sure a new row gets set 
    if ($ii == 8) { 
        $Cal_Weeks_Days .= "</tr><tr>"; 
        $ii = 1; 
    } 

    // If the day is the current day, highlight it with a special color 
    if ($Current_Day == $Day_i) { 
        $Extra = 'bgcolor="#FF0000"'; 
    } 
    else 
    { 
        // Alternate row colors 
        $Extra = 'bgcolor="#' . $color . '"'; 
    } 

    // Show the days. 
    $Cal_Weeks_Days .= '<td height="65" valign="top" ' . $Extra . '>' . $Day_i . '</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>'; 
} 

// Echo the HTML 
echo '<HTML>
<style type="text/css"> 
table,tr,td,th,tbody,TR,TD{ 
    font-family: Verdana; 
    font-size: 8pt; 
    font-size: 11; color: #000000; 
    border-font-size: 11; color: #000000; 
    border-collapse: collapse; 
} 
</style>';
echo '<table border="1" cellpadding="1" cellspacing="1" width="98%"> 
    <tr> 
        <td align="center" colspan="7" bgcolor="#999999">'.$Current_Day_Name.' the '.$Current_Day_S.' of '.$Current_Month_Name.', '.$Current_Year.'</td> 
    </tr> 
    <tr> 
        '.$Day_Names.' 
    </tr> 
    <tr> 
        '.$Cal_Weeks_Days.' 
    </tr> 
</table> 


</HTML>';

44 bugs in my java code
44 bugs in my java code
Fix 1 bug, and complie again
122 bugs in my java code

#7 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 01 April 2006 - 10:17 AM

I added a couple of sections of code hilighted between //******************** lines

// 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 events for current month and store in array, keyed by day number
$sql = "SELECT eventdate FROM events WHERE YEAR(eventdate)=$Current_Year
        AND MONTH(eventdate)=$Current_Month";
$res = mysql_query($sql) or die (mysql_error());
$month_events = array();
while ($row = mysql_fetch_row($res)) {
       $month_events[date('j', strtotime($row[0]))] = $row[0]; # store date for link
}
//************************************************************************

// 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[] = "Sunday";
$Days_Array[] = "Monday";
$Days_Array[] = "Tuesday";
$Days_Array[] = "Wednesday";
$Days_Array[] = "Thursday";
$Days_Array[] = "Friday";
$Days_Array[] = "Saturday";

// For each of the Day Names, print em out
$Day_Names = "";
foreach ($Days_Array as $x => $y) {
    $Day_Names .= '<td align="center" bgcolor="#ADADAD" width="14.28%">' . $y . '</td>';
}

// 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 = '#0000FF';
    }
    else
    {
        $color = '#0000FF';
    }

    // If the current day is sunday, make sure a new row gets set
    if ($ii == 8) {
        $Cal_Weeks_Days .= "</tr><tr>";
        $ii = 1;
    }

    // If the day is the current day, highlight it with a special color
    if ($Current_Day == $Day_i) {
        $Extra = 'bgcolor="#FF0000"';
    }
    else
    {
        // Alternate row colors
        $Extra = 'bgcolor="#' . $color . '"';
    }

    // Show the days.
    //*************************************************************************
    if (isset($month_events[$Day_i])) {   # have we an event
        $Day_i = "<a href='showEvents.php?d={$month_events[$Day_i]}'>$Day_i</a>"
    }

    //*************************************************************************
    $Cal_Weeks_Days .= '<td height="65" valign="top" ' . $Extra . '>' . $Day_i . '</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>';
}

// Echo the HTML
echo '<HTML>
<style type="text/css">
table,tr,td,th,tbody,TR,TD{
    font-family: Verdana;
    font-size: 8pt;
    font-size: 11; color: #000000;
    border-font-size: 11; color: #000000;
    border-collapse: collapse;
}
</style>';
echo '<table border="1" cellpadding="1" cellspacing="1" width="98%">
    <tr>
        <td align="center" colspan="7" bgcolor="#999999">'.$Current_Day_Name.' the '.$Current_Day_S.' of '.$Current_Month_Name.', '.$Current_Year.'</td>
    </tr>
    <tr>
        '.$Day_Names.'
    </tr>
    <tr>
        '.$Cal_Weeks_Days.'
    </tr>
</table>


</HTML>';

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#8 chriscloyd

chriscloyd
  • Members
  • PipPipPip
  • Advanced Member
  • 489 posts
  • LocationArizona

Posted 02 April 2006 - 06:08 AM

okay i made a drop down and all the events are birthdays aniversities and other how would i make the color like the css for it?
44 bugs in my java code
44 bugs in my java code
Fix 1 bug, and complie again
122 bugs in my java code

#9 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 02 April 2006 - 10:33 AM

[a href=\"http://www.w3schools.com/css/default.asp\" target=\"_blank\"]http://www.w3schools.com/css/default.asp[/a]
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#10 chriscloyd

chriscloyd
  • Members
  • PipPipPip
  • Advanced Member
  • 489 posts
  • LocationArizona

Posted 02 April 2006 - 07:13 PM

somethign happened to my script now whne i eneter an event into the database it causes the whol calendar dates to be the one i made an event for if thats making sense okay lets say i made one for 2006/04/06 as my bday ok, i would make everynumber on the calendar after the 6th the number 6 how could i fix that?
44 bugs in my java code
44 bugs in my java code
Fix 1 bug, and complie again
122 bugs in my java code

#11 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 02 April 2006 - 07:26 PM

Sorry, shouldn't have altered the value of $Day_i.

Change

    //*************************************************************************
    if (isset($month_events[$Day_i])) {   # have we an event
        $Day_i = "<a href='showEvents.php?d={$month_events[$Day_i]}'>$Day_i</a>"
    }

    //*************************************************************************

to

    //*************************************************************************
    if (isset($month_events[$Day_i])) {   # have we an event
        $DayLink = "<a href='showEvents.php?d={$month_events[$Day_i]}'>$Day_i</a>"
    }
    else $DayLink = $Day_i;

    //*************************************************************************

and in the following line, change "$Day_i " to "$DayLink"

$Cal_Weeks_Days .= '<td height="65" valign="top" ' . $Extra . '>' . $DayLink. '</td>';

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users