Jump to content

Search the Community

Showing results for tags 'mysql output'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. 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 fro 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? I have data to be rendered from mysql which I originally thought would nicely pump the variables etc into the section on the code 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 */?> $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"); } ?> =========Here is the MyEventsCalendar Page with the relevent functions etc===================== 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 == { echo "</tr>"; } } echo "</table>\n"; echo "</small>"; echo "</div>"; } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.