Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Help with Calendar - attribute eventday

    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
    Demo can be found here:http://nyken.com/test/

    The things i've added are:
    Code:
      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 >

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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:
    PHP Code:
    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!
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    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:
    PHP Code:
    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']) ?

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #5
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    oi

    Ok thanks..

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

  • #6
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •