...

View Full Version : Help with Calendar - attribute eventday



ninjaphp
02-23-2007, 04:49 PM
Hello, i've been trying to modify a already done calendar, what im trying to do is getting dates where there are an event to get an backgroundcolor.
The problem is that it does work... but if i set an event on 23' of feb i get a backgroundcolor there, which all 23' in every month get, and now i hope someone here can help me.

The whole code can be got here: http://nyken.com/test/kalender.rar (http://nyken.com/test/kalender.rar)
Demo can be found here:http://nyken.com/test/

The things i've added are:

function EventDate($estring)
{
$_GET['date'] = date("Y-m-d");
$edate = explode("-", $_GET['date']);
$eyear = $edate[0];
$emonth = $edate[1];
//$eday = $edate[2];

$esql = "SELECT subject FROM notes WHERE date = '$eyear-$emonth-$estring'";
$eresult = mysql_query($esql) or die("SQL-error <br>".mysql_error());

$ediv="ediv";
$eediv="div";

if(mysql_num_rows($eresult) > 0)
{
return $ediv;
}
else
{
return $eediv;
}

}

And then when it loop the calendar i got
'.EventDate($i).' for the div.

So in my thought this should check if there is an event on that date, which it does, but something is wrong as that date gets backgroundcolored every month >:(:confused:

Fou-Lu
02-23-2007, 11:00 PM
Lessee if I getcha right. 23 of february is fine, but it also appears on the 23rd of every month, which is not what you want correct?
Ok.
Don't want to look at the file, and its rar which I don't think I can open on my notebook, but take a look at this line:
$_GET['date'] = date("Y-m-d");
When using it in conjunction with your mysql check, its always checking against the current date, not the date given in your uri. This is because you are overriding your get data. Perhaps this is more like what you want:


if (!isset($_GET['date']) || is_empty($_GET['date'])
{
$_GET['date'] = date("Y-m-d");
}


Since your day is passed as a parameter, then you would account for that as well. According to this function, as long as the day is the $estring, then it will return true, it ignores the month and year and grabs the current month and year.
I would recommend as well using a timestamp feature instead. Numbers are far easier to work with than the split year-month-day

Hope that answers your question!

ninjaphp
02-23-2007, 11:35 PM
Lessee if I getcha right. 23 of february is fine, but it also appears on the 23rd of every month, which is not what you want correct?
Ok.
Don't want to look at the file, and its rar which I don't think I can open on my notebook, but take a look at this line:
$_GET['date'] = date("Y-m-d");
When using it in conjunction with your mysql check, its always checking against the current date, not the date given in your uri. This is because you are overriding your get data. Perhaps this is more like what you want:


if (!isset($_GET['date']) || is_empty($_GET['date'])
{
$_GET['date'] = date("Y-m-d");
}


Since your day is passed as a parameter, then you would account for that as well. According to this function, as long as the day is the $estring, then it will return true, it ignores the month and year and grabs the current month and year.
I would recommend as well using a timestamp feature instead. Numbers are far easier to work with than the split year-month-day

Hope that answers your question!

Yea it worked! thanks ^^
But isnt it enought with just checking isset($_GET['date']) ?

Fou-Lu
02-24-2007, 05:49 AM
Depends on what you do with it.
For this example, you need to ensure its not empty either. If the user enters a &date= into their url, it will flag a fatal exception. This is becase you are attempting to split a non-existant entity. At least... java would make that happen. I'm pretty sure php does the same, its been awhile and I'm kinda mixing the languages together, lol.

ninjaphp
02-24-2007, 01:16 PM
Ok thanks..

How should i do if i want to get sure that they havent put "*" in the date ?

westmatrix99
02-24-2007, 10:11 PM
First, find out if your site is set up to use PHP scripting. If so, check
out www.easyPHPcalendar.com. It's easy to use, you don't need to know
scripting to set it up.

Cheers
West



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum