SitePoint Sponsor

User Tag List

Results 1 to 15 of 15

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question function load_SpecialDays()

    Hello before all, this is my first post here, ive got this function:

    function load_SpecialDays() {
    add_SpecialDay("01-Jun-2008", 'booked')
    add_SpecialDay("4/Jun/2008", 'booked')
    add_SpecialDay("5-Jun-2008", 'booked')
    }

    And this php code:

    <?php
    include 'config.php';
    include 'opendb.php';
    $query = "select arrival from confirmed where room_id = 1";

    $result = mysql_query($query);

    while ($row = mysql_fetch_assoc($result)) {
    list( $anio, $mes, $dia ) = explode( "-", $row['arrival'] );
    echo "add_SpecialDay($dia-$mes-$anio, 'booked')<br>\n";
    }
    ?>

    It prints on screen this:

    add_SpecialDay(18-06-2008, 'booked')
    add_SpecialDay(03-07-2008, 'booked')
    add_SpecialDay(12-07-2008, 'booked')

    Could i assign this result to the function, i mean could i assign value for this result to include on load_SpecialDays()?

    Thanks in advance.
    R3g@rd$.

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ? You can echo it like you already are.

    Code php:
                function load_SpecialDays() {
                    <?php
                        include 'config.php';
                        include 'opendb.php';
                        $query = "select arrival from confirmed where room_id = 1";
     
                        $result = mysql_query($query);
     
                        while ($row = mysql_fetch_assoc($result)) {
                            list( $anio, $mes, $dia ) = explode( "-", $row['arrival'] );
                            echo "add_SpecialDay($dia-$mes-$anio, 'booked');\n";
                        }
                    ?>
                }


  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks gRoberts for your answer, maybe i havent explained well.

    Ive got showform2.php and by default it comes with some days (i delete some others) wrote manually.

    function load_SpecialDays() {
    add_SpecialDay("01-Jun-2008", 'booked')
    add_SpecialDay("4/Jun/2008", 'booked')
    add_SpecialDay("5-Jun-2008", 'booked')
    }


    This function is called by a calendar which shows this days highlighted.

    and i need to give to load_SpecialDays() this values quering sql db, so ive made the query and i gived results a format with this php code:

    <?php
    include 'config.php';
    include 'opendb.php';
    $query = "select arrival from confirmed where room_id = 1";

    $result = mysql_query($query);

    while ($row = mysql_fetch_assoc($result)) {
    list( $anio, $mes, $dia ) = explode( "-", $row['arrival'] );
    echo "add_SpecialDay($dia-$mes-$anio, 'booked');\n";
    }
    ?>
    ===============================================
    add_SpecialDay(18-06-2008, 'booked')
    add_SpecialDay(03-07-2008, 'booked')
    add_SpecialDay(12-07-2008, 'booked')

    If i do print on screen with "echo".
    ===============================================

    but i dont want to print (i only use it to test results) on screen, i would need to use this query values with load_SpecialDays() function, inserting this values into this function.

    Thanks in advance.
    R3g@rd$

  4. #4
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm confused! From what I understand, you want to use your query to generate the add_SpecialDay lines, so that you can call them when the function load_SpecialDays is called.

    My previous post provided code to do this?

    If not, then I think you need to go into more detail on what you require.

    Cheers


  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Exactly when showform2.php opens onload it makes the query and results generates function lines, so showform2.php will show calendar with this days highlighteds. If i use your code no errors appears, but calendar doesnt show this days...

    R3g@rd$ and thank you for your patience.

  6. #6
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you have a link that I can see the problem? Or could you copy the output of the code I provided? Thanks


  7. #7
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok here you are:

    How it works, when function load_SpecialDays() {
    add_SpecialDay("01-Jun-2008", 'booked')
    add_SpecialDay("4/Jun/2008", 'booked')
    add_SpecialDay("5-Jun-2008", 'booked')
    }

    http://micromercio.com/temp/showform.php -Calendar working with special days


    http://micromercio.com/temp/showform2.php - Calendar with your modification

    R3g@r$.

  8. #8
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    They don't work, they refer to localhost.

    All I want to see is when the page renders, I want to see anything inside the function load_SpecialDays().


  9. #9
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fixed.
    This is what i have.
    What do you need exactly?

  10. #10
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unfortunately that made no sense to me.

    Fixed? What is fixed? The url's still refer to localhost within the html, plus your MySQL server.

    If you load the page in your browser and view the source. Copy it and PM me it (unless you are ok with it being shown on the forum)


  11. #11
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    With your changes:
    Code:
    Use this function to add the special days
    Add the DD-MMM-YYYY, Text for the special day
    */
    function load_SpecialDays() {
                     
     
    add_SpecialDay(18-06-2008, 'booked');
    add_SpecialDay(03-07-2008, 'booked');
    add_SpecialDay(12-07-2008, 'booked');
    }
    // Call function to load all the special days
    load_SpecialDays()
    
    </script>
    
    /*
    Use this function to add the special days
    Add the DD-MMM-YYYY, Text for the special day
    */
    function load_SpecialDays() {
    add_SpecialDay("01-Jun-2008", 'booked')
    add_SpecialDay("4/Jun/2008", 'booked')
    add_SpecialDay("5-Jun-2008", 'booked')
    }
    // Call function to load all the special days
    load_SpecialDays()
    Hope it helps.
    R3g@rd$
    Last edited by akenateb; Jun 4, 2008 at 06:38.

  12. #12
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    function load_SpecialDays() {


    add_SpecialDay(18-06-2008, 'booked');
    add_SpecialDay(03-07-2008, 'booked');
    add_SpecialDay(12-07-2008, 'booked');
    }

    I think this is the problem: format must be add_SpecialDay("12-07-2008", 'booked') and we have add_SpecialDay(12-07-2008, 'booked');
    Ok i delete ";" but how can i convert this 12-07-2008 to "12-07-2008"?

    I think we can finally do it.
    R3g@rd$

  13. #13
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see whats happening...

    change

    Code php:
                            echo "add_SpecialDay($dia-$mes-$anio, 'booked');\n";
    to
    Code php:
                            echo "add_SpecialDay('$dia-$mes-$anio', 'booked');\n";


  14. #14
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It works perfectly now.
    Thank you very much.

    Best R3g@rd$.

  15. #15
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was looking this reservation calendar and i just thinking i would need the ranges between arrival and checkout day to highlight all days we have payed, actually it only shows "arrival" field.

    Ive got this field on "confirmed" table:

    - id
    - arrival
    - outg
    - room_id
    - payed

    I was looking for sql query but i only found SELECT DATEDIFF.
    Maybe a function?.

    Could someone help me?

    R3g@rd$.


Bookmarks

Posting Permissions

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