Welcome to the New Zealand Messageboards


Your forum for New Zealand topics and talk.


  •  » Want to know more about NZ?
  •  » From NZ and want to meet new people?
  •  » Have a photo to share?
  •  » Something on your mind?

...then you have come to the right place!


NZB is here for all these things.


YES! I want to register an account for free right now!


P.S: When you Register, this box vanishes!

Welcome to the New Zealand Messageboards


Your forum for New Zealand topics and talk.


  •  » Want to know more about NZ?
  •  » From NZ and want to meet new people?
  •  » Have a photo to share?
  •  » Something on your mind?

...then you have come to the right place!


NZB is here for all these things.


YES! I want to register an account for free right now!


P.S: When you Register, this box vanishes!

Results 1 to 8 of 8

Topic: Calling php coders!

              
   
  1. #1
    styx
    has no status.
    Founder
    styx's Avatar
    Join Date
    Jan 2004
    Age
    41
    Replies
    296
    Liked
    0 times
    Points
    5,907
    Level
    49
    Points: 5,907, Level: 49
    Level completed: 79%, Points required for next Level: 43
    Overall activity: 54.5%

    Default Calling php coders!

    If anyone can sort out a php problem for me, I'd be pretty darn grateful.
    I have an availability calendar (from letting-tools.com) and it creates calendar months in php, but at the moment all the months are starting on the wrong day of the week.
    I originally managed to tweak the code so that it only created the months I needed, and I hope that didn't screw up the days!
    If anyone wants to have a look, the calendar itself is at www.page1design.net/calendar/cal.php and the files involved I've archived at http://ww.page1design.net/calendar/calendar.zip
    I have emailed the original author of the utility, but his forum is shot down due to spam, and as it's a free utility I don't know if he'll have time to deal with every little complaint.
    Cheers to anyone!

  2. #2
    kall
    is tired.
    Community Manager


    kall's Avatar
    Join Date
    Jan 2004
    Location
    Auckland, New Zealan
    Age
    33
    Replies
    5,568
    Liked
    4 times
    Points
    206,456
    Level
    100
    Points: 206,456, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 100.0%
    Blog Entries
    20

    Default Re: Calling php coders!

    Pretty sure Start of Week is generally determined by the viewer's location.

    Here's something I found:

    PHP Code:
    // let's say they're in the timezone GMT+12
    $theirOffset 12;  // $_GET['offset'] perhaps?
    $offsetSeconds $theirOffset 3600;
    echo 
    gmdate("l"time() + $offsetSeconds); 

  3. #3
    styx
    has no status.
    Founder
    styx's Avatar
    Join Date
    Jan 2004
    Age
    41
    Replies
    296
    Liked
    0 times
    Points
    5,907
    Level
    49
    Points: 5,907, Level: 49
    Level completed: 79%, Points required for next Level: 43
    Overall activity: 54.5%

    Default Re: Calling php coders!

    It'd be a damn sight easier to test any theories and experiments if I could get Apache working. I had it going once, but since the new PC I can't seem to configure it properly.
    I can sort of figure out basic PHP, but without lots of referring to php.net I'm having trouble knowing the syntax of all the variables and functions.
    There are some comments in the code, and I found this:
    PHP Code:
    $date mktime(1200$month1$year);
    $daysInMonth date("t"$date);
    // calculate the position of the first day in the calendar (sunday = 1st column, etc)
    $offset date("w"$date);
    $rows 1;

    for(
    $i 1$i <= $offset$i++)
    {
        
    $new "&nbsp;|empty|";
        
    $newstringData "$newstringData"."$new";
    }
    for(
    $day 1$day <= $daysInMonth$day++)
    {
        if( (
    $day $offset 1) % == && $day != 1)
        {
        
    $new htmlspecialchars("\n");
        
    $newstringData "$newstringData"."$new";
            
    $rows++;
        }
         
    $new htmlspecialchars($day "|$state|");
            
    $newstringData "$newstringData"."$new";
    }
        while( (
    $day $offset) <= $rows 7)
        {
        
    $new "&nbsp;|empty|";
                
    $newstringData "$newstringData"."$new";
            
    $day++;
        }
    if (
    $rows == 4) {
        
    $rows++;
    $anotherline "\n&nbsp;|empty|&nbsp;|empty|&nbsp;|empty|&nbsp;|empty|&nbsp;|empty|&nbsp;|empty|&nbsp;|empty|";
        
    $newstringData "$newstringData"."$anotherline";
        }
        if (
    $rows == 5) {
    $anotherline "\n&nbsp;|empty|&nbsp;|empty|&nbsp;|empty|&nbsp;|empty|&nbsp;|empty|&nbsp;|empty|&nbsp;|empty|";
        
    $newstringData "$newstringData"."$anotherline";
        } 
    but it's all a little Greek to me just at first glance!

  4. #4
    styx
    has no status.
    Founder
    styx's Avatar
    Join Date
    Jan 2004
    Age
    41
    Replies
    296
    Liked
    0 times
    Points
    5,907
    Level
    49
    Points: 5,907, Level: 49
    Level completed: 79%, Points required for next Level: 43
    Overall activity: 54.5%

    Default Re: Calling php coders!

    No, the above code is fine - I've narrowed the problem down to a couple of other snippets;
    PHP Code:
    $month[10] = "october";
    $month[11] = "november";
    $month[12] = "december";
    $month[1] = "january";
    $month[2] = "february";
    $month[3] = "march";
    $month[4] = "april";

    // get current month to increase, was originally date('n') but I set it to 10 to try to force it
    $start 10;
    // get current year
    $year date('Y');
    //create enclosing div 
    echo '<div class="calendarwrap">';
    // create loop to run 7 times displaying the calendars
    for ($i 0$i <=6$i+=1) :
    // check if its the next year or not
        
    if ($start == 13) {
        
    // increase the year if its next year
        
    $year ++;
        
    $start 1;
            } 
    and
    PHP Code:
    function createmonth($month$year$theactualmonth) {
    include(
    "config.php");
    $month_to_check strtolower(date("F"mktime(1200$month1$year)));
    $state $default_tariffs[$month_to_check];

      
    $date mktime(1200$month1$year);
    $daysInMonth date("t"$date);
    // calculate the position of the first day in the calendar (sunday = 1st column, etc)
    $offset date("w"$date);
    $rows 1;

    for(
    $i 1$i <= $offset$i++) 
    I can sort of see what it's doing, but it's like having a basic knowledge of French, and trying to translate a Greek text using only a French-Greek dictionary!

    Problem is, the calendar was originally designed for accommodation providers to show availability all year round, and I tried to modify it to only do October-May for a fishing guide client.

    Is $month in createmonth() and mktime() the array defined in the first snippet? And if so, why isn't it simply reading "October, November" etc instead of insisting on returning "January, February" etc??

  5. #5
    kall
    is tired.
    Community Manager


    kall's Avatar
    Join Date
    Jan 2004
    Location
    Auckland, New Zealan
    Age
    33
    Replies
    5,568
    Liked
    4 times
    Points
    206,456
    Level
    100
    Points: 206,456, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 100.0%
    Blog Entries
    20

    Default Re: Calling php coders!

    Hmm. I'm not entirely fluent in php, but I can read it.

    If you use m or M instead of F in the $month_to_check line, does it make a difference, or is the output the same wrongness, just in a different form?

    Actually, I reckon that line might be the bugger.

    PHP Code:
    $month_to_check strtolower(date("F"mktime(1200$month1$year))); 
    <- why is there a 12 there? Not that I can tell for sure, but try a 0.

  6. #6
    styx
    has no status.
    Founder
    styx's Avatar
    Join Date
    Jan 2004
    Age
    41
    Replies
    296
    Liked
    0 times
    Points
    5,907
    Level
    49
    Points: 5,907, Level: 49
    Level completed: 79%, Points required for next Level: 43
    Overall activity: 54.5%

    Default Re: Calling php coders!

    Well I'm somewhat less than fluent, but I think the "F" returns the full text value of the month, which is what is referred to in config.php.
    PHP Code:
    $default_tariffs = array(
                
    "january" => "free",
                
    "february" => "free",
                
    "march" => "free",
                ); 
    etc
    And the 12,0,0, is probably just an arbitrary time on the date in question.

    PHP: mktime - Manual implies that $month is a system-generated variable from date('i') but where NOW is relevant to the calendars created I don't know.

    Damned if I can figure it out - if all my research and intuition can't clarify it, would I have any more luck if I'd ever actually learnt the language?
    Still looking . . .

  7. #7
    kall
    is tired.
    Community Manager


    kall's Avatar
    Join Date
    Jan 2004
    Location
    Auckland, New Zealan
    Age
    33
    Replies
    5,568
    Liked
    4 times
    Points
    206,456
    Level
    100
    Points: 206,456, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 100.0%
    Blog Entries
    20

    Default Re: Calling php coders!

    Yeah, F does exactly that.. I was hoping it would change nothing, indicating that it was pulling it from elsewhere.

    The 12,0,0,0 is unlike anything I have seen in the examples.. they are always like 0,0,0,0,value,value.

  8. #8
    styx
    has no status.
    Founder
    styx's Avatar
    Join Date
    Jan 2004
    Age
    41
    Replies
    296
    Liked
    0 times
    Points
    5,907
    Level
    49
    Points: 5,907, Level: 49
    Level completed: 79%, Points required for next Level: 43
    Overall activity: 54.5%

    Default Re: Calling php coders!

    I might be wiping egg from my face . . .
    It's entirely possible that I fixed it, but because createmonth() wrote a text file from which the calendar table was created, it was still working from the existing (WRONG) txt files! So for all I know, I sorted the problem and my frustration over the dates still showing wrong was unjustified! I'll have to do a test run elsewhere to see if it works . . .

Similar Topics

  1. Calling in From Papua New Guinea
    By frizzy in forum The Lounge
    Replies: 1
    Latest Reply: 22-Dec-2005, 11:17 PM
  2. Calling Aucklanders.
    By twiztid_dreams in forum The Lounge
    Replies: 3
    Latest Reply: 07-May-2005, 08:48 AM

Posting Permissions

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

Content Relevant URLs by vBSEO