Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    11
    Rep Power
    0

    PHP / MYSQL Help with Events Calendar output


    Heya Guys,
    Im hoping someone can help me or point me in the right direction for the following;

    I am currently building a reservations system for a friend and the admin area works a treat, I downloaded myEvent Calendar in the hope this would forfill the calendar aspect of the admin area for each cottage but im finding it hard knowing how to link the mysql data into the existing framework for the myEvents Calendar?

    it requires that the so called event be displayed like:

    $thisCal->addEvent(date($newcheckinDate),
    "Holiday Let Reservation, Mill Wheel </br> Bob Johnson Family </br> 01933 526655",
    "10:45 AM",
    "Reservation for 5 days");

    which is also rigged to a function somehow?

    I have data to be rendered from mysql which I originally thought would nicely pump the variables etc into the section on the code displaying it how it should but as its being called from a function im not sure how id get it to work.

    i really hope someone can help as its driving me around the twist.

    please see below for example code:





    THIS IS A Snippet From THE CALENDAR PAGE:



    <?
    require("myEventsCalendar.php");

    $thisCal = new MyEventsCalendar("/details.php");

    $thisCal->setOverlibPath("/overlib.js");

    $todaysDate = date("d") . "-" . date("m") . "-" . date("Y");


    $sqlCommand = "SELECT * FROM reservations";
    $query = mysqli_query($connection, $sqlCommand) or die (mysqli_error());
    $reservationDisplay = '';
    while ($row = mysqli_fetch_array($query)) {
    $reservationid = $row["id"];
    $propertyname = $row["propertyname"];
    $checkindate = $row["checkindate"];
    $checkoutdate = $row["checkoutdate"];
    $checkintime = $row["checkintime"];
    $checkouttime = $row["checkouttime"];
    $customerref = $row["customerref"];
    $duration = $row["duration"];
    $pets = $row["pets"];
    $f = $thisCal->addEvent;
    $newcheckinDate = preg_replace("/(\d+)\D+(\d+)\D+(\d+)/","$3-$2-$1",$checkindate);
    $reservationDisplay .= '' .$f. '(date(' .$newcheckinDate. '),"Holiday Let Reservation, Mill Wheel </br> Bob Johnson Family </br> 01933 526655","10:45 AM","Reservation for 5 days");';
    }
    mysqli_free_result($query);





    $reservationDisplay; <?php /*?>i was hoping that this variable would pump out what was required below<?php */?>


    <?php /*?>This is how the data needs to be rendered<?php */?>


    $thisCal->addEvent(date($newcheckinDate),
    "Holiday Let Reservation, Mill Wheel </br> Bob Johnson Family </br> 01933 526655",
    "10:45 AM",
    "Reservation for 5 days");



    $thisCal->addEvent(date("03-10-2013"),
    "Holiday Let Reservation, Mill Wheel </br> Bob Johnson Family </br> 01933 526655",
    "10:45 AM",
    "Reservation for 5 days");


    if($_GET["m"] && $_GET["y"]) {
    $thisCal->setMonth(trim($_GET["m"]));
    $thisCal->setDay(1);
    $thisCal->setYear(trim($_GET["y"]));
    $thisCal->generateHTML("adminhome.php?calendar=start");
    }
    else {
    $thisCal->setMonth(date("m"));
    $thisCal->setDay(1);
    $thisCal->setYear(date("Y"));
    $thisCal->generateHTML("adminhome.php?calendar=start");
    }

    ?>







    ========= Here is the MyEventsCalendar Page with the relevent functions etc from MyEventsCalendar =====================

    Sorry for the long page etc

    <?php

    /*
    * myEventsCalendar Class
    *
    **/

    class myEventsCalendar
    {
    var $month = 0, $day = 0, $year = 0;
    var $Months = Array("January", "February","March", "April", "May", "June", "July",
    "August", "September", "October", "November", "December");

    var $overlibPath = "", $eventsId = array(), $eventsData = array(), $eventsCount = 0;

    var $formDetailsAction = "";

    function myEventsCalendar($thisFormDetailsAction)
    {
    //set the destination to view event detail
    $this->formDetailsAction = $thisFormDetailsAction;

    //set additional parameters if necessary
    //need to set month, day, and year
    //before generating HTML
    $this->eventsData = array();
    $this->eventsCount = count($this->eventsData);
    }

    /**Append the parameter element to the vector*/
    function addEvent($thisDate,$thisEventTitle, $thisEventTime, $thisEventDescription)
    {
    if(!empty($thisDate))
    {
    $dateArr = explode("-",$thisDate);
    $mIndex = intVal($dateArr[0]);
    $dIndex = intVal($dateArr[1]);
    $yIndex = intVal($dateArr[2]);

    $dateIndex = $mIndex . "-" . $dIndex . "-" . $yIndex;

    if(!$this->eventsId[$dateIndex]) {
    $this->eventsId[$dateIndex] = 1;
    }
    else {
    $numOfEvents = intVal($this->eventsId[$dateIndex]);
    $numOfEvents = $numOfEvents + 1;
    $this->eventsId[$dateIndex] = $numOfEvents;
    }

    $titleIdx = "title" . $this->eventsId[$dateIndex];
    $timeIdx = "time" . $this->eventsId[$dateIndex];
    $descrIdx = "description" . $this->eventsId[$dateIndex];

    $this->eventsData[$dateIndex][$titleIdx] = $thisEventTitle;
    $this->eventsData[$dateIndex][$timeIdx] = $thisEventTime;
    $this->eventsData[$dateIndex][$descrIdx] = $thisEventDescription;

    $this->eventsCount = count($this->eventsData);

    return true;
    }
    else
    return false;
    }

    function setMonth($thisMonth)
    {
    $this->month = $thisMonth;
    }

    function setYear($thisYear)
    {
    $this->year = $thisYear;
    }

    function setDay($thisDay)
    {
    $this->day = $thisDay;
    }

    function setOverlibPath($thisPath)
    {
    $this->overlibPath = $thisPath;
    }

    function getDayOfMonth($month, $day, $year)
    {
    $myresult = date("l", mktime(0, 0, 0, $month, $day, $year));
    return $myresult;
    }

    function getMonthName($month, $day, $year)
    {
    $myresult = date("F", mktime(0, 0, 0, $month, $day, $year));
    return $myresult;
    }

    function getWeekDay($day)
    {
    $myresult = 0;

    switch ($day) {
    case "Monday": $myresult = 1; break;
    case "Tuesday": $myresult = 2; break;
    case "Wednesday": $myresult = 3; break;
    case "Thursday": $myresult = 4; break;
    case "Friday": $myresult = 5; break;
    case "Saturday": $myresult = 6; break;
    case "Sunday": $myresult = 7; break;
    }
    return $myresult;
    }

    function getNumDaysOfMonth($month, $year)
    {
    // non-leap year
    $nonleap = Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

    // leap year
    $leap = Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

    $isLeap = false ;

    if (($year % 4) == 0) {
    if (($year % 100) == 0 && ($year % 400) != 0) {
    $isLeap = false;
    } else {
    $isLeap = true;
    }
    } else {
    $isLeap = false;
    }

    if($isLeap == true) {
    return $leap[$month - 1];
    } else {
    return $nonleap[$month - 1];
    }
    }

    function isToday($month,$day,$year)
    {
    if( ($month == intval(date("m"))) && ( $day == intval(date("d")))
    && ($year == intval(date("Y")))){
    return true;
    } else {
    return false;
    }

    }

    //Some book keeping
    function getDetails($thisDate, $allDetails)
    {
    $counter = 1;
    $titleIdx = "title" . $counter;
    $timeIdx = "time" . $counter;
    $descrIdx = "description" . $counter;
    $result = "";

    //prepare overlib data
    while($this->eventsData[$thisDate][$titleIdx] != "") {

    if($counter > 1){ $result .= "<br><br>"; }

    $result .= "<b>Reservation Details:</b> " . $this->eventsData[$thisDate][$titleIdx];
    $result .= "<br><b>Check in Time:</b> " . $this->eventsData[$thisDate][$timeIdx];
    if($allDetails) {
    $result .= "<br><b>Summary:</b> " . $this->eventsData[$thisDate][$descrIdx];
    }

    $counter = $counter + 1;
    $titleIdx = "title" . $counter;
    $timeIdx = "time" . $counter;
    $descrIdx = "description" . $counter;

    }
    return $result;
    }

    //This function takes the parameters month, day, and year and
    //queries the global array with the event information for any
    //relevant events that occur on that date
    function outputDay($thisMonth,$thisDay,$thisYear)
    {
    $thisDate = $thisMonth . "-" . $thisDay . "-" . $thisYear;

    if($this->eventsId[$thisDate]) {
    $overlib = $this->getDetails($thisDate, false);
    $details = $this->getDetails($thisDate, true);

    echo "<table style='background-color:#006699;' width='40' height='40' border='0' cellspacing='0' cellpadding='2'>
    <tr>
    <td><div class='Reservation'><a style='background-color:#006699; color:#fff; font-weight:bold; height:40px; width:40px;' href=\"javascript:goToDetails('" . urlencode($details) . "')";
    echo ";\" ";
    echo "onmouseover=\"return overlib('" . $overlib . "',";
    echo "CAPTION,";
    echo "'" . $thisDate . "');\" ";
    echo "onmouseout=\"return nd();\">". $thisDay ."</a>\n</div></td>
    </tr>
    </table>";

    } else {
    echo $thisDay;
    }
    }

    //This function loops through the days available in the month and
    //outputs each day accordingly. If an event is found, then it will
    //add a link for that day which shows a preview on an overlib effect,
    // and upon click, it takes the user to the corresponding details page
    function generateHTML($toUrl)
    {
    //configure top navigation
    $nextMonth = $this->month + 1;
    $nextYear = $this->year;

    if($nextMonth == 13) {
    $nextMonth = 1;
    $nextYear = $this->year + 1;
    }

    $prevMonth = $this->month - 1;
    $prevYear = $this->year;

    if($prevMonth == 0) {
    $prevMonth = 12;
    $prevYear = $this->year - 1;
    }

    //output overlib js path
    echo "<script type=\"text/javascript\" src=\"" . $this->overlibPath . "\"></script>";

    //output overlib div
    echo "<div class='EventOverlay' id=\"overDiv\" style=\"position:absolute; visibility:hidden; z-index:1000;\"></div>";

    //output detail form
    echo "<form name=\"jump_to_details\" action=\"" . $this->formDetailsAction . "\" ";
    echo "method=\"POST\">\n";
    echo "<input type=\"hidden\" name=\"event\" value=\"\">\n";
    echo "</form>";

    //output javascript submit form (handler) method
    echo "<script language=\"Javascript\">\n";
    echo "\n";
    echo "function goToDetails(thisEvent) {\n";
    echo "document.jump_to_details.event.value=thisEvent\n";
    echo "document.jump_to_details.submit()\n";
    echo "}\n";
    echo "</script>\n";

    //configure bottom navigation
    $gobackwards = $toUrl . "&m=" . $prevMonth . "&y=" . $prevYear;
    $goforward = $toUrl . "&m=" . $nextMonth . "&y=" . $nextYear;

    echo "<div class='CalendarHolder' style='background-color:#f3f3f3; border: 2px solid #ccc; padding:4px; border-radius:6px; width:400px;'>";
    echo "<div class='CottageTitle'";
    echo "<h2>Mill Wheel Cottage Reservations Calendar</h2>";
    echo "</div>";
    echo "<small>";
    echo "<table style='background-color:#f3f3f3; padding:10px;' cellpadding=\"10\">\n";
    echo "<tr>\n";
    echo " <td colspan=\"7\">";
    echo " <table style='background-color:#fff; border: 1px solid #ccc; padding:10px;' cellpadding=\"0\" width=\"100%\">\n";
    echo " <tr>\n";
    echo " <td width=\"5%\"><a href=\"" . $gobackwards .
    "\"><img src='/Template/images/Previous.jpg' width='50' height='50' alt='Previous Month' /></a></td>\n";
    echo " <td width=\"90%\" align=\"center\"><b style='font:Arial, Helvetica, sans-serif; font-size:16px; color:#333; text-align:center'>" .
    $this->getMonthName($this->month , 1 , $this->year) .
    " " . $this->year . "</b></td>\n";
    echo " <td width=\"5%\"><a href=\"" . $goforward .
    "\"><img src='/Template/images/Next.jpg' width='50' height='50' alt='Previous Month' /></a></td>\n";
    echo " </tr>\n";
    echo " </table>\n";
    echo " </td>";
    echo "</tr>\n";
    echo "<tr>\n";
    echo " <td style='background-color:#fff;'><b>Sun</b></td>\n";
    echo " <td style='background-color:#fff;'><b>Mon</b></td>\n";
    echo " <td style='background-color:#fff;'><b>Tue</b></td>\n";
    echo " <td style='background-color:#fff;'><b>Wed</b></td>\n";
    echo " <td style='background-color:#fff;'><b>Thu</b></td>\n";
    echo " <td style='background-color:#fff;'><b>Fri</b></td>\n";
    echo " <td style='background-color:#fff;'><b>Sat</b></td>\n";
    echo "</tr>\n";

    $newrow = 1;
    $monLoop = $this->getNumDaysOfMonth($this->month, $this->year);
    $startDay = intval($this->getWeekDay($this->getDayOfMonth(
    $this->month, 1, $this->year)));
    $begin = false;

    for($i=1; $i <= $monLoop; $i++) {

    if($startDay == 7) {
    $begin = true;
    }

    if($newrow == 8 || $newrow == 1) {
    echo "<tr style='background-color:#fff; padding:0px;'>";
    $newrow = 1;
    }

    if($begin == true) {

    if( $this->isToday($this->month, $i, $this->year)) {
    echo " <td><font color=\"red\">";
    $this->outputDay(intVal($this->month), intVal($i), intVal($this->year));
    echo "</font></td>";
    } else {
    echo " <td>";
    $this->outputDay(intVal($this->month), intVal($i), intVal($this->year));
    echo "</td>";
    }
    }

    if($i <= $startDay && $begin == false ) {

    echo " <td> </td>";

    if($i == $startDay) {
    $begin = true;
    $i = 0;
    }
    }

    $newrow++;

    if($newrow == 8) {
    echo "</tr>";
    }

    }

    echo "</table>\n";

    echo "</small>";
    echo "</div>";
    }

    }

    ?>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,623
    Rep Power
    595
    First you need to edit your post and enclose your code in [ PHP ] tags. See the sticky at the top of this forum. Due to the size of your code it is very difficult to read.
    Second, you are using the deprecated MySQL extensions so you need to switch to PDO.
    Third, you indicate what you SHOULD get but you do not say what you DO get and why it is wrong.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    11
    Rep Power
    0

    Thanks for the reply, ok....


    Thanks for the quick reply, here is the shortened version to what i think is wrong,

    thanks for the headsup on the depreciated mysql extensions could you point me in the right direction of PDO,

    The error is that nothing is happening, im trying to replicate the bookings below by an output of the query which when i echo looks the same but when i take away the echo its just the calendar still only with the hardcoded bookings,

    hope this helps and hope ive done it right this time.



    PHP Code:

      
    require("myEventsCalendar.php"); 

      
    $thisCal = new MyEventsCalendar("/details.php");

      
    $thisCal->setOverlibPath("/overlib.js");

      
    $todaysDate date("d") . "-" date("m") . "-" date("Y");
                                                                                                              
    $sqlCommand "SELECT * FROM reservations LIMIT 5"
    $query mysqli_query($connection$sqlCommand) or die (mysqli_error());
    $reservationDisplay '';
    while (
    $row mysqli_fetch_array($query)) { 
        
    $reservationid $row["id"];
        
    $propertyname $row["propertyname"];
        
    $checkindate $row["checkindate"];
        
    $checkoutdate $row["checkoutdate"];
        
    $checkintime $row["checkintime"];
        
    $checkouttime $row["checkouttime"];
        
    $customerref $row["customerref"];
        
    $duration $row["duration"];
        
    $pets $row["pets"];
        
    $newcheckinDate preg_replace("/(\d+)\D+(\d+)\D+(\d+)/","$2-$1-$3",$checkindate);
        
    $dateinfo "' .$thisCal->. 'addEvent(date(' .$newcheckinDate. '),";
        
    $reservationDisplay .= "' .$dateinfo. ','Holiday Let Reservation, Mill Wheel </br> Bob Johnson Family </br> 01933 526655,'
                         '10:45 AM,'
                         'Reservation for 5 days');"
    ;

    mysqli_free_result($query); 

                  
                         
    $reservationDisplay
                         
                         
    $thisCal->addEvent(date($newcheckinDate),
                         
    "Holiday Let Reservation, Mill Wheel </br> Bob Johnson Family </br> 01933 526655",
                         
    "10:45 AM",
                         
    "Reservation for 5 days");
     
                         
    $thisCal->addEvent(date("03") . "-" date("10") . "-" date("2013"),
                         
    "Holiday Let Reservation, Mill Wheel </br> Bob Johnson Family </br> 01933 526655",
                         
    "10:45 AM",
                         
    "Reservation for 5 days"); 
    right..
    the above mysql query renders out perfectly the way the code should be but when i view the page it doesnt do anything,
    The idea is that the calendar will highlight the days a reservation is booked on, the 2 above are hard coded versions but i would like to work out away to do it dynamically so that i may use mysql.

    i will be happy to send you a link to the page etc if you have an email address? it doesnlt allow me to put mine on here?

    the blue squares are a result of hard coded events not dynamic.

    this is some how linked to the following function:


    PHP Code:

     
    function addEvent($thisDate,$thisEventTitle$thisEventTime$thisEventDescription)
      {
            if(!empty(
    $thisDate))
            {
                
    $dateArr explode("-",$thisDate);
                
    $mIndex intVal($dateArr[0]);
                
    $dIndex intVal($dateArr[1]);
                
    $yIndex intVal($dateArr[2]);

                
    $dateIndex $mIndex "-" $dIndex "-" $yIndex;
                
                if(!
    $this->eventsId[$dateIndex]) {
                    
    $this->eventsId[$dateIndex] = 1;
                }
                else {
                  
    $numOfEvents intVal($this->eventsId[$dateIndex]);
                  
    $numOfEvents $numOfEvents 1;
                  
    $this->eventsId[$dateIndex] = $numOfEvents;
                }
                
                
    $titleIdx "title" $this->eventsId[$dateIndex];
                
    $timeIdx "time" $this->eventsId[$dateIndex];
                
    $descrIdx "description" $this->eventsId[$dateIndex];
                
                
    $this->eventsData[$dateIndex][$titleIdx] = $thisEventTitle;
                
    $this->eventsData[$dateIndex][$timeIdx] = $thisEventTime;
                
    $this->eventsData[$dateIndex][$descrIdx] = $thisEventDescription;

                
    $this->eventsCount count($this->eventsData);

                return 
    true;
            }
            else
                return 
    false;
      } 
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,623
    Rep Power
    595
    For PDO, go here. As for displaying the page, post the code that does that.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    11
    Rep Power
    0

    code and page display


    right a link to the page so you can see what the main idea is:

    www (dot) management (dot) woodfordmilltearooms (dot) co (dot) uk / adminhome (dot) php

    sorry it wont let me post links here,

    do you want both full pages of script as there quite long?
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,623
    Rep Power
    595
    Just post the section of PHP code that is going wrong.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    11
    Rep Power
    0

    I already have


    The bit that is going wrong is the bit above, i already have posted it, it doesnt look wrong to me thats why im on the forums, for some insight, this is my first time on a support forum so please bear with me

    i need to basically output

    addEvent(date($newcheckinDate),
    "Holiday Let Reservation, Mill Wheel </br> Bob Johnson Family </br> 01933 526655",
    "10:45 AM",
    "Reservation for 5 days");

    dynamically with the call to the addEvent function,

    my attempt at this was:

    PHP Code:
    $sqlCommand "SELECT * FROM reservations"
    $query mysqli_query($connection$sqlCommand) or die (mysqli_error());
    $reservationDisplay '';
    while (
    $row mysqli_fetch_array($query)) { 
        
    $reservationid $row["id"];
        
    $propertyname $row["propertyname"];
        
    $checkindate $row["checkindate"];
        
    $checkoutdate $row["checkoutdate"];
        
    $checkintime $row["checkintime"];
        
    $checkouttime $row["checkouttime"];
        
    $customerref $row["customerref"];
        
    $duration $row["duration"];
        
    $pets $row["pets"];
        
    $newcheckinDate preg_replace("/(\d+)\D+(\d+)\D+(\d+)/","$3-$2-$1",$checkindate);
        
    $reservationDisplay .= '$thisCal->addEvent(date(' .$newcheckinDate'),
                         "' 
    .$checkintime'Holiday Let Reservation, Mill Wheel </br> Bob Johnson Family </br> 01933 526655",
                         "10:45 AM",
                         "Reservation for 5 days");'
    ;

    mysqli_free_result($query); 
    but its not doing anything its blank with the calendar the same as before?

    thank you for your help i truly do appreciate it.
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    11
    Rep Power
    0
    PHP Code:
    $thisCal->addEvent(date($newcheckinDate),
                         
    "Holiday Let Reservation, Mill Wheel </br> Bob Johnson Family </br> 01933 526655",
                         
    "10:45 AM",
                         
    "Reservation for 5 days"); 
    this is what is need to be rendered out dynamically with the query if possible.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,623
    Rep Power
    595
    I guess I am not understanding your problem. I see nothing that outputs any HTML.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    11
    Rep Power
    0
    heya,

    im not trying to output any html im tring to get this to render dynamic results from the query within a php script,

    the script has the example above written into it and i want to try and replace this dynamically if possible.
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,623
    Rep Power
    595
    Render dynamic results where? You mentioned "blank page" earlier. Sorry, but I'm just not getting it.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    11
    Rep Power
    0

    dynamic results


    Originally Posted by gw1500se
    Render dynamic results where? You mentioned "blank page" earlier. Sorry, but I'm just not getting it.
    Its not your fault im just rubbish at explaining myself some times

    ok..

    the page for the calendar is as follows

    PHP Code:
      require("myEventsCalendar.php"); 

      
    $thisCal = new MyEventsCalendar("/details.php");

      
    $thisCal->setOverlibPath("/overlib.js");

      
    $todaysDate date("d") . "-" date("m") . "-" date("Y");
                                                                                                              

                         
                         
    $thisCal->addEvent(date($newcheckinDate),
                         
    "Holiday Let Reservation, Mill Wheel </br> Bob Johnson Family </br> 01933 526655",
                         
    "10:45 AM",
                         
    "Reservation for 5 days");
     
                         
    $thisCal->addEvent(date("03") . "-" date("10") . "-" date("2013"),
                         
    "Holiday Let Reservation, Mill Wheel </br> Bob Johnson Family </br> 01933 526655",
                         
    "10:45 AM",
                         
    "Reservation for 5 days");
                         
      
      if(
    $_GET["m"] && $_GET["y"]) { 
        
    $thisCal->setMonth(trim($_GET["m"])); 
        
    $thisCal->setDay(1);
        
    $thisCal->setYear(trim($_GET["y"]));
        
    $thisCal->generateHTML("adminhome.php?calendar=start"); 
      } 
      else { 
        
    $thisCal->setMonth(date("m")); 
        
    $thisCal->setDay(1);
        
    $thisCal->setYear(date("Y"));
        
    $thisCal->generateHTML("adminhome.php?calendar=start"); 
      } 

    ?> 
    there is a call to a function within the php code that is the following:

    PHP Code:
    $thisCal->addEvent(date($newcheckinDate),
                         
    "Holiday Let Reservation, Mill Wheel </br> Bob Johnson Family </br> 01933 526655",
                         
    "10:45 AM",
                         
    "Reservation for 5 days"); 
    it appears this is calling the add event function from the other page which is:


    PHP Code:
    function addEvent($thisDate,$thisEventTitle$thisEventTime$thisEventDescription)
      {
            if(!empty(
    $thisDate))
            {
                
    $dateArr explode("-",$thisDate);
                
    $mIndex intVal($dateArr[0]);
                
    $dIndex intVal($dateArr[1]);
                
    $yIndex intVal($dateArr[2]);

                
    $dateIndex $mIndex "-" $dIndex "-" $yIndex;
                
                if(!
    $this->eventsId[$dateIndex]) {
                    
    $this->eventsId[$dateIndex] = 1;
                }
                else {
                  
    $numOfEvents intVal($this->eventsId[$dateIndex]);
                  
    $numOfEvents $numOfEvents 1;
                  
    $this->eventsId[$dateIndex] = $numOfEvents;
                }
                
                
    $titleIdx "title" $this->eventsId[$dateIndex];
                
    $timeIdx "time" $this->eventsId[$dateIndex];
                
    $descrIdx "description" $this->eventsId[$dateIndex];
                
                
    $this->eventsData[$dateIndex][$titleIdx] = $thisEventTitle;
                
    $this->eventsData[$dateIndex][$timeIdx] = $thisEventTime;
                
    $this->eventsData[$dateIndex][$descrIdx] = $thisEventDescription;

                
    $this->eventsCount count($this->eventsData);

                return 
    true;
            }
            else
                return 
    false;
      } 
    I want to replace the hard coded event eg:$thisCal->addEvent(date($newcheckinDate),
    "Holiday Let Reservation, Mill Wheel </br> Bob Johnson Family </br> 01933 526655",
    "10:45 AM",
    "Reservation for 5 days");

    with a dynamic result if possible from the following query:

    PHP Code:
     <?php
    $sqlCommand 
    "SELECT * FROM reservations"
    $query mysqli_query($connection$sqlCommand) or die (mysqli_error());
    $reservationDisplay '';
    while (
    $row mysqli_fetch_array($query)) { 
        
    $reservationid $row["id"];
        
    $propertyname $row["propertyname"];
        
    $checkindate $row["checkindate"];
        
    $checkoutdate $row["checkoutdate"];
        
    $checkintime $row["checkintime"];
        
    $checkouttime $row["checkouttime"];
        
    $customerref $row["customerref"];
        
    $duration $row["duration"];
        
    $pets $row["pets"];
        
    $newcheckinDate preg_replace("/(\d+)\D+(\d+)\D+(\d+)/","$3-$2-$1",$checkindate);
        
    $reservationDisplay .= '$thisCal->addEvent(date(' .$newcheckinDate'),
                         "' 
    .$checkintime'Holiday Let Reservation, Mill Wheel </br> Bob Johnson Family </br> 01933 526655",
                         "10:45 AM",
                         "Reservation for 5 days");'
    ;

    mysqli_free_result($query); 
    ?>
    sorry for all of the ball ache its been sending me mad for days.
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,623
    Rep Power
    595
    OK, I think I see now. However, among the variables you get from the query, which correspond to the hard coded values? For example, which variable contains the equivalent of 'Holiday Let Reservation, Mill Wheel'? I am not seeing the correlation between the hard coded values and the data extracted from the database.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  26. #14
  27. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    11
    Rep Power
    0
    Originally Posted by gw1500se
    OK, I think I see now. However, among the variables you get from the query, which correspond to the hard coded values? For example, which variable contains the equivalent of 'Holiday Let Reservation, Mill Wheel'? I am not seeing the correlation between the hard coded values and the data extracted from the database.
    Sorry the mill wheel etc is dummy stuff that i can replace later soon as i get a primitave version working, the value that mainly needs outputting dynamically is the $checkindate which ends up as
    $newcheckinDate as the query reformats the date.

    When this works what it should do is replace the hard coded value and populate the calendar the same way the hard coded ones do

    thanks for your time and patience it is greatly appreciated!
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,623
    Rep Power
    595
    So if you are extracting the check-in date from the database, why are you using the 'date' function? What are you expecting it to do? The string you pass to that function should be a format string. See the documentation.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo