/    Sign up×
Community /Pin to ProfileBookmark

design question

I want to have an events calendar where the data is stored in the database.
I eventually hope to tie into an Outlook calendar to populate the database which will then populate a php page.

My question deals with the best way to implement a revolving calendar in the db. Is there an easy way to do this? How do I put this in the db and handle the changing years? Just keep 2 years calendar in the db and constantly update one as the year passes?

Any suggestions would be appreciated.

Thanks
Rut

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@bathurst_guyDec 06.2005 — Is the calendar on [url=http://brcc.org.au/]this site[/url] what your talking about.
Copy linkTweet thisAlerts:
@rutledjauthorDec 06.2005 — Yes. Something along those lines is what I'm thinking. How did you implement this in the database as far as having all the months? Or did you just do one month at a time?

Thanks,

Rut
Copy linkTweet thisAlerts:
@NewZealandDec 07.2005 — http://phpicalendar.net/ may be what you want, it stores all your information and you can inport/export many calander programs calander information to it.
Copy linkTweet thisAlerts:
@bathurst_guyDec 08.2005 — Database is set up like this:
CREATE TABLE <span><code>calendar</code></span> (
<span><code>title</code></span> varchar(255) NOT NULL default '',
<span><code>event</code></span> text,
<span><code>userid</code></span> varchar(255) NOT NULL default '',
<span><code>event_type</code></span> varchar(50) default NULL,
<span><code>event_finish</code></span> datetime NOT NULL default '0000-00-00 00:00:00',
<span><code>received</code></span> datetime NOT NULL default '0000-00-00 00:00:00',
<span><code>entered</code></span> datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (<span><code>received</code></span>,<span><code>userid</code></span>)
) TYPE=MyISAM;

And all the rest is php which I just include in each page
[code=php]<?php
// Check for a Month Change submission

if ($_POST[calendar]) {
$calendar = $_POST[calendar];
// Subtract one from the month for previous, add one for next

if ($calendar == "Prev") {
$_SESSION[month_now] = $_SESSION[month_now] - 1;
} else {
$_SESSION[month_now] = $_SESSION[month_now] + 1; }

$date = getdate(mktime(0,0,0,$_SESSION[month_now],1,$_SESSION[year_now]));

} else if (isset($_SESSION[month_now])){

$date = getdate(mktime(0,0,0,$_SESSION[month_now],1,$_SESSION[year_now]));

} else {
$date = getdate();
}

$month_num = $date["mon"];
$month_name = $date["month"];
$year = $date["year"];
$date_today = getdate(mktime(0,0,0,$month_num,1,$year));
$first_week_day = $date_today["wday"];
$cont = true;
$today = 27;

while (($today <= 32) && ($cont)) {
$date_today = getdate(mktime(0,0,0,$month_num,$today,$year));

if ($date_today["mon"] != $month_num) {
$lastday = $today - 1;
$cont = false;
}

$today++;
}

// allow for form submission to the script for forward and backwards

echo"
<p style="text-align: center;"><strong>$month_name $year</strong></p>
<table style="margin: 0 auto;">
<tr><td class="day">S</td><td class="day">M</td><td class="day">T</td><td class="day">W</td><td class="day">T</td><td class="day">F</td><td class="day">S</td></tr>";

// begin placement of days according to their beginning weekday

$day = 1;
$wday = $first_week_day;
$firstweek = true;
while ( $day <= $lastday) {
if ($firstweek) {
echo "<TR>";
for ($i=1; $i<=$first_week_day; $i++) {

echo "<TD> </td>";
}
$firstweek = false;
}
if ($wday==0) {
echo "<tr>";
}

// make each day linkable to the following result.php page


if ( intval($month_num) < 10) { $new_month_num = "0$month_num"; }
elseif (intval($month_num) >= 10) { $new_month_num = $month_num; }
if ( intval($day) < 10) { $new_day = "0$day"; }
elseif (intval($day) >= 10) { $new_day = $day; }
$link_date = "$year-$new_month_num-$new_day";

$sql = "SELECT * from calendar where received LIKE '$link_date%' LIMIT 1";
$result = mysql_query($sql, $db) or die ("Invalid query");



if (!mysql_num_rows($result)) {

echo "<td";
if ($link_date == date(Y."-".m."-".d)){
echo " style="border:2px solid #339;"";
}else if ($link_date == $eventid){
echo " style="border:2px solid #99f;"";
};
echo "><a href="results.php?eventid=$link_date"> $day </a></td>";
} else {

echo "<td";
if ($link_date == date(Y."-".m."-".d)){
echo " style="border:2px solid #339;"";
}else if ($link_date == $eventid){
echo " style="border:2px solid #99f;"";
};
echo "><strong><a href="results.php?eventid=$link_date" style="color: #f00;}"> $day </a></strong></td>";
}


if ($wday==6) {
echo "</tr>n";
}

$wday++;
$wday = $wday % 7;
$day++;
}
$today = getdate();
$_SESSION[month_now] = $month_num;
$_SESSION[year_now] = $year;
echo"
</table>
<form action="".$_SERVER[PHP_SELF]."" method="POST" name="calendar">
<p style="text-align: center;">
<input type="submit" name="calendar" value="Prev">
<input type="submit" name="calendar" value="Next">
";
if (isset($_GET[eventid])){
echo "<input type="hidden" name="eventid" value="$_GET[eventid]">";
} else if (isset($_POST[eventid])){
echo "<input type="hidden" name="eventid" value="$_POST[eventid]">";
}
echo"
</p>
</form>
<p style="text-align: center;"><em>(Days in red contain <br>events or information)</em></p>";
?>[/code]
And you should be able to make your own results.php
×

Success!

Help @rutledj spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...