PHP - I Want To Disable A Specific Day On Calendar Help
<?php class booking_diary { // Mysqli connection function __construct($link) { $this->link = $link; } // Settings you can change: // Time Related Variables public $booking_start_time = "09:00"; // The time of the first slot in 24 hour H:M format public $booking_end_time = "13:00"; // The time of the last slot in 24 hour H:M format public $booking_frequency = 02; // The slot frequency per hour, expressed in minutes. //$date = new DateTime(); //$Pdate-> setDate(2020, 10, 29); // Day Related Variables public $day_format = 1; // Day format of the table header. Possible values (1, 2, 3) // 1 = Show First digit, eg: "M" // 2 = Show First 3 letters, eg: "Mon" // 3 = Full Day, eg: "Monday" public $day_closed = array("Saturday", "Sunday"); // If you don't want any 'closed' days, remove the day so it becomes: = array(); //public $Special_day = array() public $day_closed_text = "CLOSED"; // If you don't want any any 'closed' remove the text so it becomes: = ""; // Cost Related Variables public $cost_per_slot = 20.00; // The cost per slot public $cost_currency_tag = "£"; // The currency tag in HTML such as € £ ¥ // DO NOT EDIT BELOW THIS LINE public $day_order = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); public $day, $month, $year, $selected_date, $back, $back_month, $back_year, $forward, $forward_month, $forward_year, $bookings, $count, $days, $is_slot_booked_today; /*========================================================================================================================================================*/ function make_calendar($selected_date, $back, $forward, $day, $month, $year) { // $day, $month and $year are the $_GET variables in the URL $this->day = $day; $this->month = $month; $this->year = $year; // $back and $forward are Unix Timestamps of the previous / next month, used to give the back arrow the correct month and year $this->selected_date = $selected_date; $this->back = $back; $this->back_month = date("m", $back); $this->back_year = date("Y", $back); // Minus one month back arrow $this->forward = $forward; $this->forward_month = date("m", $forward); $this->forward_year = date("Y", $forward); // Add one month forward arrow // Make the booking array $this->make_booking_array($year, $month); } function make_booking_array($year, $month, $j = 0) { $stmt = $this->link->prepare("SELECT name, date, start FROM bookings WHERE date LIKE CONCAT(?, '-', ?, '%')"); $this->is_slot_booked_today = 0; // Defaults to 0 $stmt->bind_param('ss', $year, $month); $stmt->bind_result($name, $date, $start); $stmt->execute(); $stmt->store_result(); while($stmt->fetch()) { $this->bookings_per_day[$date][] = $start; $this->bookings[] = array( "name" => $name, "date" => $date, "start" => $start ); // Used by the 'booking_form' function later to check whether there are any booked slots on the selected day if($date == $this->year . '-' . $this->month . '-' . $this->day) { $this->is_slot_booked_today = 1; } } // Calculate how many slots there are per day $this->slots_per_day = 0; for($i = strtotime($this->booking_start_time); $i<= strtotime($this->booking_end_time); $i = $i + $this->booking_frequency * 60) { $this->slots_per_day ++; } $stmt->close(); $this->make_days_array($year, $month); } // Close function function make_days_array($year, $month) { // Calculate the number of days in the selected month $num_days_month = cal_days_in_month(CAL_GREGORIAN, $month, $year); // Make $this->days array containing the Day Number and Day Number in the selected month for ($i = 1; $i <= $num_days_month; $i++) { // Work out the Day Name ( Monday, Tuesday... ) from the $month and $year variables $d = mktime(0, 0, 0, $month, $i, $year); // Create the array $this->days[] = array("daynumber" => $i, "dayname" => date("l", $d)); } /* Sample output of the $this->days array: [0] => Array ( [daynumber] => 1 [dayname] => Monday ) [1] => Array ( [daynumber] => 2 [dayname] => Tuesday ) */ $this->make_blank_start($year, $month); $this->make_blank_end($year, $month); } // Close function function make_blank_start($year, $month) { /* Calendar months start on different days Therefore there are often blank 'unavailable' days at the beginning of the month which are showed as a grey block The code below creates the blank days at the beginning of the month */ // Get first record of the days array which will be the First Day in the month ( eg Wednesday ) $first_day = $this->days[0]['dayname']; $s = 0; // Loop through $day_order array ( Monday, Tuesday ... ) foreach($this->day_order as $i => $r) { // Compare the $first_day to the Day Order if($first_day == $r && $s == 0) { $s = 1; // Set flag to 1 stop further processing } elseif($s == 0) { $blank = array( "daynumber" => 'blank', "dayname" => 'blank' ); // Prepend elements to the beginning of the $day array array_unshift($this->days, $blank); } } // Close foreach } // Close function function make_blank_end($year, $month) { /* Calendar months start on different days Therefore there are often blank 'unavailable' days at the end of the month which are showed as a grey block The code below creates the blank days at the end of the month */ // Add blank elements to end of array if required. $pad_end = 7 - (count($this->days) % 7); if ($pad_end < 7) { $blank = array( "daynumber" => 'blank', "dayname" => 'blank' ); for ($i = 1; $i <= $pad_end; $i++) { array_push($this->days, $blank); } } // Close if $this->calendar_top(); } // Close function function calendar_top() { // This function creates the top of the table containg the date and the forward and back arrows echo " <div id='lhs'><div id='outer_calendar'> <table border='0' cellpadding='0' cellspacing='0' id='calendar'> <tr id='week'> <td align='left'><a href='?month=" . date("m", $this->back) . "&year=" . date("Y", $this->back) . "'>«</a></td> <td colspan='5' id='center_date'>" . date("F, Y", $this->selected_date) . "</td> <td align='right'><a href='?month=" . date("m", $this->forward) . "&year=" . date("Y", $this->forward) . "'>»</a></td> </tr> <tr>"; /* Make the table header with the appropriate day of the week using the $day_format variable as user defined above Definition: 1: Show First digit, eg: "M" 2: Show First 3 letters, eg: "Mon" 3: Full Day, eg: "Monday" */ foreach($this->day_order as $r) { switch($this->day_format) { case(1): echo "<th>" . substr($r, 0, 1) . "</th>"; break; case(2): echo "<th>" . substr($r, 0, 3) . "</th>"; break; case(3): echo "<th>" . $r . "</th>"; break; } // Close switch } // Close foreach echo "</tr>"; $this->make_cells(); } // Close function function make_cells($table = '') { echo "<tr>"; foreach($this->days as $i => $r) { // Loop through the date array $j = $i + 1; $tag = 0; // If the the current day is found in the day_closed array, bookings are not allowed on this day if(in_array($r['dayname'], $this->day_closed)) { echo "\r\n<td width='21' valign='top' class='closed'>" . $this->day_closed_text . "</td>"; $tag = 1; } // Past days are greyed out if (mktime(0, 0, 0, $this->month, sprintf("%02s", $r['daynumber']) + 1, $this->year) < strtotime("now") && $tag != 1) { echo "\r\n<td width='21' valign='top' class='past'>"; // Output day number if($r['daynumber'] != 'blank') echo $r['daynumber']; echo "</td>"; $tag = 1; } // If the element is set as 'blank', insert blank day if($r['dayname'] == 'blank' && $tag != 1) { echo "\r\n<td width='21' valign='top' class='unavailable'></td>"; $tag = 1; } // Now check the booking array $this->booking to see whether we have a booking on this day $current_day = $this->year . '-' . $this->month . '-' . sprintf("%02s", $r['daynumber']); if(isset($this->bookings_per_day[$current_day]) && $tag == 0) { $current_day_slots_booked = count($this->bookings_per_day[$current_day]); if($current_day_slots_booked < $this->slots_per_day) { echo "\r\n<td width='21' valign='top'> <a href='calendar.php?month=" . $this->month . "&year=" . $this->year . "&day=" . sprintf("%02s", $r['daynumber']) . "' class='part_booked' title='This day is part booked'>" . $r['daynumber'] . "</a></td>"; $tag = 1; } else { echo "\r\n<td width='21' valign='top'> <a href='calendar.php?month=" . $this->month . "&year=" . $this->year . "&day=" . sprintf("%02s", $r['daynumber']) . "' class='fully_booked' title='This day is fully booked'>" . $r['daynumber'] . "</a></td>"; $tag = 1; } // Close else } // Close if if($tag == 0) { echo "\r\n<td width='21' valign='top'> <a href='calendar.php?month=" . $this->month . "&year=" . $this->year . "&day=" . sprintf("%02s", $r['daynumber']) . "' class='green' title='Please click to view bookings'>" . $r['daynumber'] . "</a></td>"; } // The modulus function below ($j % 7 == 0) adds a <tr> tag to every seventh cell + 1; if($j % 7 == 0 && $i >1) { echo "\r\n</tr>\r\n<tr>"; // Use modulus to give us a <tr> after every seven <td> cells } } echo "</tr></table></div><!-- Close outer_calendar DIV -->"; if(isset($_GET['year'])) $this->basket(); echo "</div><!-- Close LHS DIV -->"; // Check booked slots for selected date and only show the booking form if there are available slots $current_day = $this->year . '-' . $this->month . '-' . $this->day; $slots_selected_day = 0; if(isset($this->bookings_per_day[$current_day])) $slots_selected_day = count($this->bookings_per_day[$current_day]); if($this->day != 0 && $slots_selected_day < $this->slots_per_day) { $this->booking_form(); } } // Close function function booking_form() { echo " <div id='outer_booking'><h2>Available Slots</h2> <p> The following slots are available on <span> " . $this->day . "-" . $this->month . "-" . $this->year . "</span> </p> <table width='400' border='0' cellpadding='2' cellspacing='0' id='booking'> <tr> <th width='150' align='left'>Start</th> <th width='150' align='left'>End</th> <th width='150' align='left'>Price</th> <th width='20' align='left'>Book</th> </tr> <tr> <td> </td><td> </td><td> </td><td> </td> </tr>"; // Create $slots array of the booking times for($i = strtotime($this->booking_start_time); $i<= strtotime($this->booking_end_time); $i = $i + $this->booking_frequency * 60) { $slots[] = date("H:i:s", $i); } // Loop through $this->bookings array and remove any previously booked slots if($this->is_slot_booked_today == 1) { // $this->is_slot_booked_today created in function 'make_booking_array' foreach($this->bookings as $i => $b) { if($b['date'] == $this->year . '-' . $this->month . '-' . $this->day) { // Remove any booked slots from the $slots array $slots = array_diff($slots, array($b['start'])); } // Close if } // Close foreach } // Close if // Loop through the $slots array and create the booking table foreach($slots as $i => $start) { // Calculate finish time $finish_time = strtotime($start) + $this->booking_frequency * 60; echo " <tr>\r\n <td>" . $start . "</td>\r\n <td>" . date("H:i:s", $finish_time) . "</td>\r\n <td>" . $this->cost_currency_tag . number_format($this->cost_per_slot, 2) . "</td>\r\n <td width='110'><input data-val='" . $start . " - " . date("H:i:s", $finish_time) . "' class='fields' type='checkbox'></td> </tr>"; } // Close foreach echo "</table></div><!-- Close outer_booking DIV -->"; } // Close function function basket($selected_day = '') { if(!isset($_GET['day'])) $day = '01'; else $day = $_GET['day']; // Validate GET date values if(checkdate($_GET['month'], $day, $_GET['year']) !== false) { $selected_day = $_GET['year'] . '-' . $_GET['month'] . '-' . $day; } else { echo 'Invalid date!'; exit(); } echo "<div id='outer_basket'> <h2>Selected Slots</h2> <div id='selected_slots'></div> <div id='basket_details'> <form method='post' action='book_slots.php'> <label>Name</label> <input name='name' id='name' type='text' class='text_box'> <label>Email</label> <input name='email' id='email' type='text' class='text_box'> <label>Phone</label> <input name='phone' id='phone' type='text' class='text_box'> <div id='outer_price'> <div id='currency'>" . $this->cost_currency_tag . "</div> <div id='total'></div> </div> <input type='hidden' name='slots_booked' id='slots_booked'> <input type='hidden' name='cost_per_slot' id='cost_per_slot' value='" . $this->cost_per_slot . "'> <input type='hidden' name='booking_date' value='" . $_GET['year'] . '-' . $_GET['month'] . '-' . $day . "'> <input type='submit' class='classname' value='Make Booking'> </form> </div><!-- Close basket_details DIV --> </div><!-- Close outer_basket DIV -->"; } // Close function } // Close Class ?> Edited October 29, 2020 by requinix please use the Code <> button when posting code Similar TutorialsHi, I have my website located at /home/public_html. I have a folder used by my web managers at /home/public_html/dev. The web managers only have the permissions to access the contents of that dev directory and no other directory on the website. But, is there a way to disable certain dangerous functions like shell_exec() only in /home/public_html/dev ? I know you can disable functions in php.ini, but the problem is that if I put the php.ini file in the /home/public_html/dev directory, it could easily be changed (on my shared host it's not possible to change owner/group permissions). Putting the php.ini file with the disabled functions list in /home/public_html works great in preventing the dev folder from using them since its in an inaccessible location to the web managers, but unfortunately that also prevents me from using the functions in public_html, where they are needed. One possible solution I was thinking could involve writing an .htaccess conditional statement, but I'm not quite such how to accomplish that. Here is what I would need to do in my .htaccess file: Code: [Select] IF DIRECTORY == /home/public_html/dev { suPHP_ConfigPath /home/public_html/php.ini # Sets the location of the php.ini file to use. # I know suPHP_ConfigPath works perfectly, just need to know how to do the conditional } I would have the above .htaccess file as well as the php.ini file with the restrictions located in /home/public_html, but it would ideally only use that php.ini file with the restrictions within the dev folder. Does anyone know how to accomplish the above conditional statement, or some other solution which would allow me to disable certain PHP functions for the dev directory without affecting the public_html directory or having the php.ini file directly in the dev directory? Thanks! I use the Wholesale Suite Premium Prices plugin with WooCommerce. I have 6 specific wholesale roles out of 15 that I wish to hide two specific shipping methods from being selected for the 6 exceptions. I'm just trying this on my staging server at this time using a code snippet example that I found and modified for my specific conditions. Would the following work for this purpose? /* Hide specific shipping methods for specific wholesale roles */ add_filter( 'woocommerce_package_rates', function( $shipping_rates ) { // User role and shipping method ID to hide for the user role $role_shipping_method_arr = array( 'ws_silvia_silver' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_silver_pst_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_silver_tax_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_silver' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_silver_pst_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_silver_tax_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_gold' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_gold_pst_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_gold_tax_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_gold' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_gold_pst_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_gold_tax_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), ); // Getting the current user role $curr_user = wp_get_current_user(); $curr_user_data = get_userdata($current_user->ID); // Wholesale Suite Roles if (isset($current_user) && class_exists('WWP_Wholesale_Roles')) { $wwp_wholesale_roles = WWP_Wholesale_Roles::getInstance(); $wwp_wholesale_role = $wwp_wholesale_roles->getUserWholesaleRole(); // Loop through the user role and shipping method pair foreach( $role_shipping_method_arr as $role => $shipping_methods_to_hide ) { // Check if defined role exist in current user role or not if( in_array( $role, $current_user->roles) ) { // Loop through all the shipping rates foreach( $shipping_rates as $shipping_method_key => $shipping_method ) { $shipping_id = $shipping_method->get_id(); // Unset the shipping method if found if( in_array( $shipping_id, $shipping_methods_to_hide) ) { unset($shipping_rates[$shipping_method_key]); } } } } } return $shipping_rates; }); Any insights as to how to accomplish this would be greatly appreciated. Lyse ok so I have this code. I need to know how to modify it so that if the user has already registered for the event, they cannot do so again.........how can I do this? does this make sense? members that have already registered are held in a table called events..........userid, eventid, name, subevent....... Code: [Select] <?php $sql = mysql_query("SELECT * FROM Registration WHERE eventid=".$_GET['eventid']." LIMIT 1"); while($row = mysql_fetch_array($sql)){ $eventid = $row["eventid"]; $event = $row["event"]; $startdate = $row["startdate"]; $enddate = $row["enddate"]; $description = $row["description"]; $location = $row["location"]; $title1 = $row['title1']; $title2 = $row['title2']; $title3 = $row['title3']; $title4 = $row['title4']; $title5 = $row['title5']; $title6 = $row['title6']; $title7 = $row['title7']; $title8 = $row['title8']; $price1 = $row['price1']; $price2 = $row['price2']; $price3 = $row['price3']; $price4 = $row['price4']; $price5 = $row['price5']; $price6 = $row['price6']; $price7 = $row['price7']; $price8 = $row['price8']; $date1 = $row['date1']; $date2 = $row['date2']; $date3 = $row['date3']; $date4 = $row['date4']; $date5 = $row['date5']; $date6 = $row['date6']; $date7 = $row['date7']; $date8 = $row['date8']; //this will echo the contents of each db row as they are iterated in the loop ############################# echo "<form action ='eventreg.php' method='post'>"; echo "<center><table border='1' width='600'>"; if (!empty($title1)) { echo "<tr><td width='100'> <input type='checkbox' name='subevent1' value='$title1'/></td><td width='500'><strong>$title1 </strong><br /> $date1 <br />$ $price1 </tr></td> "; } if (!empty($title2)) { echo "<br/><tr><td> <input type='checkbox' name='subevent2' value='$title2' /></td><td><strong>$title2 </strong><br /> $date2 <br />$ $price2 </tr></td>" ; } if (!empty($title3)) { echo "<br/><tr><td><input type='checkbox' name='subevent3' value='$title3' /></td><td><strong>$title3</strong> <br /> $date3 <br />$ $price3</tr></td>"; } if (!empty($title4)) { echo "<br/><tr><td><input type='checkbox' name='subevent4' value='$title4' /></td><td><strong>$title4</strong> <br /> $date4 <br />$ $price4</tr></td>"; } if (!empty($title5)) { echo "<br/><tr><td><input type='checkbox' name='subevent5' value='$title5' /></td><td><strong>$title5</strong> <br /> $date5 <br />$ $price5</tr>"; } if (!empty($title6)) { echo "<br/><tr><td> <input type='checkbox' name='subevent6' value='$title6' /></td><td><strong>$title6 </strong><br /> $date6 <br />$ $price6</tr></td>"; } if (!empty($title7)) { echo "<br/><tr><td> <input type='checkbox' name='subevent7' value='$title7' /></td><td><strong>$title7</strong> <br /> $date7 <br />$ $price7</tr></td>"; } if (!empty($title8)) { echo "<br/><tr><td> <input type='checkbox' name='subevent8' value='$title8' /></td><td><strong>$title8</strong> <br /> $date8 <br />$ $price8</tr></td>"; } echo "</table>"; echo "<input name='userid' type=\"hidden\" value=\"$userid\" />"; echo "<input name='eventid' type=\"hidden\" value=\"$eventid\" />"; echo "<input name='event' type=\"hidden\" value=\"$event\" />"; echo "<input name='name' type=\"hidden\" value=\"$name\" />"; echo "<input name=\"save\" type=\"submit\" value=\"Register Now!\" />"; echo "</center></form>"; } //etc etc ?> hi, i have implemented a calendar in php and added contols to display the previous and next months. How will I enhance my code to add links to display the previous and next year calendars? My code is as follows: Code: [Select] <?php session_start(); $_SESSION['username']; $_SESSION['unique_id']; $username = $_SESSION['username']; $unique_id = $_SESSION['unique_id']; ?> <?php $host = "localhost"; $user=""; $password=""; $db_name=""; $tbl_name=""; $con = mysql_connect("localhost","",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$db_name", $con); // Now we need to define "A DAY", which will be used later in the script: define("ADAY", (60*60*24)); // The rest of the script will stay the same until about line 82 if ((!isset($_GET['month'])) || (!isset($_GET['year']))) { $nowArray = getdate(); $month = $nowArray['mon']; //mon - Numeric representation of a month $year = $nowArray['year']; } else { $month = $_GET['month']; $year = $_GET['year']; } $start = mktime(12,0,0,$month,1,$year); $firstDayArray = getdate($start); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title><?php echo "Calendar: ".$firstDayArray['month']."" . $firstDayArray['year']; ?></title> <link type="text/css" href="css/style_inner.css" rel="stylesheet" /> </head> <body> <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>" style="padding-top:50px"> <?php /* "next month" control */ $next_month = '<a href="?month='.($month != 12 ? $month + 1 : 1).'&year='.($month != 12 ? $year : $year + 1).'" class="control" style="text-decoration:none; padding-left:50px;">Next Month ></a>'; /* "previous month" control */ $previous_month = '<a href="?month='.($month != 1 ? $month - 1 : 12).'&year='.($month != 1 ? $year : $year - 1).'" class="control" style="text-decoration:none; padding-left:200px; padding-right:50px;">< Previous Month</a>'; /*$next_year = '<a href="?year='.($year != 2050 ? $year + 1 : 1).'&year='.($year != 2050 ? $year : $year + 1).'" class="control" style="text-decoration:none; padding-left:10px;">Next Year >></a>'; $previous_year = '<a href="?month='.($year != 2011 ? $year - 1 : 2050).'&year='.($year != 2011 ? $year : $year - 1).'" class="control" style="text-decoration:none; padding-left:150px;"><< Previous Year</a>'; echo $previous_year;*/ echo $previous_month; ?> <select name="month"><br/> <?php $months = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); for ($x=1; $x<=count($months); $x++){ echo "<option value=\"$x\""; if ($x == $month){ echo " selected"; } echo ">".$months[$x-1]."</option>"; } ?> </select> <select name="year"> <?php for ($x=2011; $x<=2050; $x++){ echo "<option"; if ($x == $year){ echo " selected"; } echo ">$x</option>"; } ?> </select> <input type="submit" name="submit" value="Go!"> <?php echo $next_month; /*echo $next_year;*/ ?> </form> <br /> <?php $days = Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); echo "<table border=\"1\" style=\"padding-left:100px;\"><tr>\n"; foreach ($days as $day) { echo "<td style=\"background-color: #000000; width: 100px\" align=\"center\"> <strong style=\"color:#FFFFFF;\">$day</strong></td>\n"; } for ($count=0; $count < (6*7); $count++) { $dayArray = getdate($start); if (($count % 7) == 0) { if ($dayArray["mon"] != $month) { break; } else { echo "</tr><tr>\n"; } } if ($count < $firstDayArray["wday"] || $dayArray["mon"] != $month) { //wday - Numeric representation of the day of the week echo "<td height=\"110px\"> </td>\n"; } else { //mday - Numeric representation of the day of the month $chkEvent_sql = "SELECT event_title, event_shortdesc FROM calendar_events WHERE month(event_start) = '".$month."' AND dayofmonth(event_start) = '".$dayArray["mday"]."' AND year(event_start) = '".$year."' ORDER BY event_start"; $chkEvent_res = mysql_query($chkEvent_sql, $con) or die(mysql_error($con)); if (mysql_num_rows($chkEvent_res) > 0) { $event_title = "<br/>"; while ($ev = mysql_fetch_array($chkEvent_res)) { $event_title .= "<font color=\"#006600\">" . stripslashes($ev["event_title"])."</font><br/>"; //$event_shortdesc .= stripslashes($ev["event_shortdesc"])."<br/>"; } mysql_free_result($chkEvent_res); } else { $event_title = ""; $event_shortdesc = ""; } echo "<td height=\"110px\" style=\"color : #0000CC;\">".$dayArray["mday"]."<a href=\"event.php?m=".$month."&d=".$dayArray["mday"]."&y=".$year."\" style=\"text-decoration:none;\"><img src=\"images/Add Event.jpg\" alt=\"Add Event\" title=\"Add Event\" height=\"20px\" width=\"20px\" style=\"padding-left:20px;\"/></a><br/>".$event_title."</td>\n"; unset($event_title); $start += ADAY; } } echo "</tr></table>"; mysql_close($con); ?> </body> </html> Please help me out its urgent.. Thank you in advance... Hello Guys, My goal is to make a Php and SQL calendar. I started learning php and sql a while ago, and basically got distracted. I'm now back, with a new project in the unhelpful position of having forgotten most of what I had learnt! I am making a project where I want to make a booking system. I have 3 rooms that are available to be booked Room 1, Room 2 and Room 3. I want to make a table that displays the current year in the top row, with the option to be able to click on a '<' or a '>' to change years. I want the same option for months and weeks. I think I am happy with how I would do this. The next bit is more tricky. I want a column for each of the days of the week. directly under this I want to display the correct date, under the correct day, starting with the current week we are on. for example it might look like this: ------------------------------------------- | < 2012 > | ------------------------------------------- | < March > | ------------------------------------------- | < 2 > | ------------------------------------------- |mon | tues | wed| thur | fri | sat | sun | | 5th | 6th | 7th| 8th |9th |10th| 11th | --------------------------------------------- Room 1 | yes | | | | | | | ---------------------------------------------- Room 2 | | | yes | | | | | ---------------------------------------------- Room 3 | | | | |yes | | | ---------------------------------------------- Although at the moment I'm struggling with the whole flippin' thing, the main issue is getting the correct dates to line up under the correct days of the week. I'm not asking for you to do this for me- but a bit of gentle help in this, and maybe some general advice in what I'm trying to achieve would be really useful! Regards, AJLX
Good Evening ! little help or a lot please ? I have coded a calendar on my site and am now trying to input the data info from MySQL into the calendar by PHP for each corresponding date...the calendar code works but I cant figure out how to get the info that's submitted in to the specified/corresponding date in the calendar :/ but I can get it to the bottom of the page. I've been at this 3 days and a million searches to find an example to follow but now I am at my wits end ! been about 15 years since I've done this. PLEASE help :) and thank you so much The HTML is good I can add to it if needed but the problem area is the calendar portion and putting it all in the right place without an error or code issue. I'm not sure how much more information i can provide. Like I said I am still trying to remember all of this stuff and trying to teach myself again and im not having much luck but i am a fast learner and can pickup by seeing how the code is written usually Here is my code: or at least the PHP portion of it. I hope this helps. <?php /*MAKES THE CONNECTION*/ include 'config.php'; $conn = mysqli_connect($servername, $username, $password, $dbname); // CHECK CONNECTION if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } /*DRAWS CALENDAR*// function draw_calendar($month,$year){ $calendar = '<table cellpadding="0" cellspacing="0" class="calendar">'; $headings = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); $calendar.= '<tr class="calendar-row"><td class="calendar-day-head">'.implode('</td><td class="calendar-day-head">',$headings).'</td></tr>'; $running_day = date('w',mktime(0,0,0,$month,1,$year)); $days_in_month = date('t',mktime(0,0,0,$month,1,$year)); $days_in_this_week = 1; $day_counter = 0; $dates_array = array(); $start_day = $calendar.= '<tr class="calendar-row">'; for($x = 0; $x < $running_day; $x++): $calendar.= '<td class="calendar-day-np"> </td>'; $days_in_this_week++; endfor; for($list_day = 1; $list_day <= $days_in_month; $list_day++): $calendar.= '<td class="calendar-day">'; /* add in the day number */ $calendar.= '<div class="day-number">'.$list_day.'</div>'; /** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !! IF MATCHES FOUND, PRINT THEM !! **/ $sql = "SELECT * FROM $tablename WHERE $current_epoch BETWEEN $start_day AND $end_day"; /** NEED TOQUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !! IF MATCHES FOUND, PRINT THEM !! **/ $calendar.= str_repeat('<p>'.$start_day.'</p>',2); $calendar.= '</td>'; if($running_day == 6): $calendar.= '</tr>'; if(($day_counter+1) != $days_in_month): $calendar.= '<tr class="calendar-row">'; endif; $running_day = -1; $days_in_this_week = 0; endif; $days_in_this_week++; $running_day++; $day_counter++; endfor; if($days_in_this_week < 8): for($x = 1; $x <= (8 - $days_in_this_week); $x++): $calendar.= '<td class="calendar-day-np"> </td>'; endfor; endif; /* final row */ $calendar.= '</tr>'; /* end the table */ $calendar.= '</table>'; return $calendar; } $sql = "SELECT id, name, phone, item, start_day, end_day, start_time, end_time FROM $tablename"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo $calendar. "id: " . $row["id"]. " - Name: " . $row["name"]. " - Phone: " . $row["phone"]. " - Item: " . $row["item"]. " - Start Day: " . $row["start_day"]. " - End Day: " . $row["end_day"]. " - Start Time: " . $row["start_time"]. " - End Time: " . $row["end_time"]. "<br>"; } } else { echo "0 results"; } /*END OF SHOWINGCALENDAR_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ */ $sql = "SELECT id, name, phone, item, start_day, end_day, start_time, end_time FROM $tablename"; $result = $conn->query($sql); /*GETS THE RESULTS OF THE CALENDAR FROM DATABASE TABLE*/ if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo $calendar. "id: " . $row["id"]. " - Name: " . $row["name"]. " - Phone: " . $row["phone"]. " - Item: " . $row["item"]. " - Start Day: " . $row["start_day"]. " - End Day: " . $row["end_day"]. " - Start Time: " . $row["start_time"]. " - End Time: " . $row["end_time"]. "<br>"; } } else { echo "0 results"; } Edited January 18 by Isfun42ofus Hello there! I've been at this for too long! I've got a normal calendar at the side of my website that works fine, however i would like one that shows the next 7 days starting at today. I have an image here that kind of shows what i want... So it will show the next 7 days starting with today, and going into the next month if todays date is the 30th etc. Could anybody please help me? :\ Ok, so I have a field in database called shutoff( a date when registrations will no longer be accepted for an event). How can I make it so that on the specified date, the register button will change to "no longer accepting Registrations". here is the form: Code: [Select] <?php // when displaying an article show a link // to see the article list if(isset($_GET['eventid'])) { ?> <div id="info " > <p>Date(s): <?php echo $startdate; ?><span class="klgjsa"> -</span> <?php echo $enddate; ?><br /> <span class="fgsdfg">Location:</span> <?php echo $location; ?><br /> <span class="adfasdf">Description</span><span class="adfdas">: </span><?php echo $description; ?> </p> <p> </p> <center> <table width="577" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="565" bgcolor="#C5C0B7" class="hjkh" scope="col"><?php echo $event; ?><font color='#C5C0B7'>...........................</font> <font size='-1'> <?php if ($accounttype =='Admin'){ echo "<a href='cofirmation.php'>Confirm Registrations </a><font color='#C5C0B7'>...</font><a href='quickregister.php?eventid=".$_GET['eventid']."'>Quick Registration</a><font color='#C5C0B7'>...</font><a href='viewregistered.php?eventid=".$_GET['eventid']."'>View Registrations</a>"; } ?></font></td> </tr> <tr> <td bgcolor="#999999" class="hjkh" scope="col"><table width="576" border="1" cellspacing="0" cellpadding="1"> <tr> <td width="91" bgcolor="#FFFFFF" scope="col"><?php $sql = mysql_query("SELECT * FROM Registration WHERE eventid=".$_GET['eventid']." LIMIT 1"); while($row = mysql_fetch_array($sql)){ $event= $row["event"]; $subevent1 = $row['subevent1']; $subevent2 = $row['subevent2']; $subevent3 = $row['subevent3']; $subevent4 = $row['subevent4']; $subevent5 = $row['subevent5']; $subevent6 = $row['subevent6']; $subevent7 = $row['subevent7']; $subevent8 = $row['subevent8']; $title1 = $row['title1']; $title2 = $row['title2']; $title3 = $row['title3']; $title4 = $row['title4']; $title5 = $row['title5']; $title6 = $row['title6']; $title7 = $row['title7']; $title8 = $row['title8']; $price1 = $row['price1']; $price2 = $row['price2']; $price3 = $row['price3']; $price4 = $row['price4']; $price5 = $row['price5']; $price6 = $row['price6']; $price7 = $row['price7']; $price8 = $row['price8']; $date1 = $row['date1']; $date2 = $row['date2']; $date3 = $row['date3']; $date4 = $row['date4']; $date5 = $row['date5']; $date6 = $row['date6']; $date7 = $row['date7']; $date8 = $row['date8']; //this will echo the contents of each db row as they are iterated in the loop ############################# if (!empty($title1)) { echo "<br/><strong>$title1</strong><br />$date1<br />$ $price1<br /><br />"; } if (!empty($title2)) { echo "<br/><strong>$title2</strong><br />$date2<br />$ $price2<br /><br />"; } if (!empty($title3)) { echo "<br/><strong>$title3</strong><br />$date3<br />$ $price3<br /><br />"; } if (!empty($title4)) { echo "<br/><strong>$title4</strong><br />$date4<br />$ $price4<br /><br />"; } if (!empty($title5)) { echo "<br/><strong>$title5</strong><br />$date5<br />$ $price5<br /><br />"; } if (!empty($title6)) { echo "<br/><strong>$title6</strong><br />$date6<br />$ $price6<br /><br />"; } if (!empty($title7)) { echo "<br/><strong>$title7</strong><br />$date7<br />$ $price7<br /><br />"; } if (!empty($title8)) { echo "<br/><strong>$title8</strong><br />$date8<br />$ $price8"; } } //etc etc ?></td> <td width="475" bgcolor="#FFFFFF" scope="col"><?php echo $description; ?></td> </tr> </table></td> </tr> </table> <table width="200" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="31" scope="col"><?php if (isset($_GET['eventid'])) { include('connect1.php'); $sql = "SELECT eventid FROM Registration WHERE eventid=".$_GET['eventid']." LIMIT 1"; $result = mysqli_query($dbcon, $sql) or die('error getting data'); echo "<table>"; $row = mysqli_fetch_array($result, MYSQLI_ASSOC); echo "<tr><td>"; echo "<form action='registration.php' method='get'><input type='hidden' name='eventid' value='{$row['eventid']}'><INPUT TYPE='submit' name='submit' VALUE='Register'></form>\n"; echo "</td></tr>"; echo "</table>"; } ?></td> </tr> </table></center> <p> </p> <table width="200" border="0" cellspacing="0" cellpadding="0"> <tr> <th scope="col"> </th> </tr> </table> <p><?php } ?> and here is where data is pulled: Code: [Select] $query = "SELECT event, description, startdate, enddate, location, subevent1, subevent2, subevent3, subevent4, subevent5, subevent6, subevent7, subevent8, price1, price2, price3, price4, price5, price6, price7, price8, shutoff FROM Registration WHERE eventid=".$_GET['eventid']; $result = mysql_query($query) or die('Error : ' . mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $startdate = $row['startdate']; $enddate = $row['enddate']; $location = $row['location']; $description = $row['description']; $event= $row["event"]; $subevent1 = $row['subevent1']; $subevent2 = $row['subevent2']; $subevent3 = $row['subevent3']; $subevent4 = $row['subevent4']; $subevent5 = $row['subevent5']; $subevent6 = $row['subevent6']; $subevent7 = $row['subevent7']; $subevent8 = $row['subevent8']; $title1 = $row['title1']; $title2 = $row['title2']; $title3 = $row['title3']; $title4 = $row['title4']; $title5 = $row['title5']; $title6 = $row['title6']; $title7 = $row['title7']; $title8 = $row['title8']; $price1 = $row['price1']; $price2 = $row['price2']; $price3 = $row['price3']; $price4 = $row['price4']; $price5 = $row['price5']; $price6 = $row['price6']; $price7 = $row['price7']; $price8 = $row['price8']; $date1 = $row['date1']; $date2 = $row['date2']; $date3 = $row['date3']; $date4 = $row['date4']; $date5 = $row['date5']; $date6 = $row['date6']; $date7 = $row['date7']; $date8 = $row['date8']; $shutoff = $row['shutoff']; does this make sense? it is in yyyy-mm-dd format(I believe that is correct...... ok, so I have this code for my event registration page......I need to make this event register button dissapear after the date has passed.......can I do this using dd/mm/yyyy or do i need yyyy-mm-dd? here is the codeif ($reg_end == date("F",strtotime("+1 month"))){ echo "<form action='registration.php' method='get'><input type='hidden' name='eventid' value='{$row['eventid']}'><INPUT TYPE='submit' name='submit' VALUE='Register'></form>\n";} else{echo "No longer accepting registrations";} also I need to know how to modify the red code to do this........thanks in advance.......btw I will have field call reg_end which is when the turn off date is....... Hi Everyone,
I am really struggling with this.....Cannot find a solution anywhere.
I have a website with SSL installed.
I would like to force SSL on the whole website but not on 2 urls.
If my whole site is https://mysite.com
and the 2 urls to disable from the SSL a
http://mysite.com/hotels
http://mysite.com/weather
How can I do it via htaccess please?
Thank you so much,
Ben
hello, is there a simple way to have a full size calendar that shows current month and on each day, it will look into my mysql table and if i have an entry on that day, show the sales field. i have spent days googling, and trying my own and i just cant get anything. if i had a calendar script, i could do the rest, but i cant seem to find it, or make it. I got this Event Calendar Script off of a site and i like it but it reads from a Flat File Database and i would like it to read from a mysql database. Can someone help me set it up so it will read from a mysql database? here is the script where its calling from the flat file.. Code: [Select] $counterfilepath="calendar.txt"; if(file_exists($counterfilepath)) { $filehandle=fopen($counterfilepath,"r"); $pointer = 1; while(!feof($filehandle)) { $rowdata = fgets($filehandle); $day = floatval(substr($rowdata,3,2)); $eventlastpos = strpos($rowdata,'{')-1; if($eventlastpos<=0){$eventlastpos=255;} $event = rtrim(substr($rowdata,11,$eventlastpos-10)); $eventcaption = rtrim(substr($rowdata,$eventlastpos+2,strlen($rowdata))); $datalist = $this->eventsthismonth[$day]; $rowmonth = floatval(substr($rowdata,0,2)); $rowyear = floatval(substr($rowdata,6,4)); if($rowmonth==$month and $rowyear==$year) { if($eventcaption=="") {$eventcaption='';} else {$eventcaption='<b>'.$eventcaption.'</b><br>';} if($datalist=="") { $this->eventsthismonth[$day] = '<font name=Verdana size=1>'.$eventcaption.$event.'</font>'; } else { $this->eventsthismonth[$day] = $datalist.'<br><hr size=1 color=#E0E0E0><font name=Verdana size=1>'.$eventcaption.$event.'</font>'; } } $pointer = $pointer + 1; } fclose($filehandle); } and the flat file looks like this 07/13/2005|Technology Advisory Meeting{2:00pm Hello! First I would like to say welcome to the forums! I hope one day I'll be able to give back!! Anyway, I seem to not know how to do this. I'm creating a website for my guild, and I'm very very rusty with PHP (learned it a year or two back than lost it). Anyway, I made the script to display the calendar portion of it (followed a tutorial), but I can't seem to import the feature to display events in the same cell as the date that its on. Sorry my coding is a little sloppy but I'm hoping you guys can help xD I left off with thinking that maybe i could use an array to do the job but I honestly have no clue how to go about this... Code: [Select] <?php function calendar(){ include('connect.php'); $month = date("n"); $year = date("Y"); $query = "SELECT * FROM calendar WHERE (month='$month' AND year='$year')"; $result = mysql_query($query); $num = mysql_num_rows($result); $firstDay1 = mktime(0,1,0,$month,1,$year); $firstDay = mktime(0,1,0,$month,1,$year); $daysInMonth = date("t",$firstDay); $firstDay = date("w",$firstDay); $day1 = array(); $message = array(); $message1 = ''; $dayNumber = 1; $i = 0; while ($i < $num) { $day1[$i] = mysql_result($result,$i,"day"); $message[$i] = mysql_result($result,$i,"message"); $i++; } echo "<table width='280' border='1'>\n"; echo "<tr>\n"; echo "<td align='center'>" . date("F Y") . "</td>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<td>\n"; echo "<table width='490' border='0' cellspacing='2' cellpadding='2'>\n"; echo "<tr align='center'>\n"; echo "<td width='70'>Sun</td>\n"; echo "<td width='70'>Mon</td>\n"; echo "<td width='70'>Tue</td>\n"; echo "<td width='70'>Wed</td>\n"; echo "<td width='70'>Thu</td>\n"; echo "<td width='70'>Fri</td>\n"; echo "<td width='70'>Sat</td>\n"; echo "</tr>\n"; # Calculate number of rows $totalCells = $firstDay + $daysInMonth; if($totalCells < 36){ $rowNumber = 5; } else { $rowNumber = 6; } # Create Rows for($currentRow=1; $currentRow <= $rowNumber; $currentRow++){ if($currentRow == 1){ # Create First Row echo "<tr align='center'>\n"; for($currentCell = 0; $currentCell<7; $currentCell++){ if($currentCell == $firstDay){ # First Day of the Month if($day1 == $dayNumber){ $message1 = $message; } else { $message1 = ""; } echo "<td width='70' height='50'>" . $dayNumber . "<br />$message1</td>\n"; $dayNumber++; } else { if($dayNumber > 1){ # First Day Passed so output Date if($day1 == $dayNumber){ $message1 = $message; } else { //$message1 = ""; } echo "<td width='70' height='50'>" . $dayNumber . "<br />$message1</td>\n"; $dayNumber++; } else { # First Day Not Reached so display blank cell echo "<td width='70' height='50'> </td>\n"; } } } echo "</tr>\n"; } else { # Create Remaining Rows echo "<tr align='center'>\n"; for($currentCell = 0; $currentCell < 7; $currentCell++){ if($dayNumber > $daysInMonth){ # Days in month exceeded so display blank cell echo "<td width='70' height='50'> </td>\n"; } else { if($day1 == $dayNumber){ $message1 = $message; } else { $message1 = ""; } echo "<td width='70' height='50'>" . $dayNumber . "<br />$message1</td>\n"; $dayNumber++; } } echo "</tr>\n"; } } echo "</table>\n"; echo "</td>\n"; echo "</tr>\n"; echo "</table>\n"; } calendar(); ?> Thank you guys so much!!! It will mean alot to me and my guild xD!! **EDIT** Forgot to add, Database looks like this id day month year message Thanks again! howdy all I was wondering if anyone has any Basic Event calendar or a tutorial for a basic one.. I want to get a event calendar on my site but i want a basic one so i can tweak it to fit my likings. Thank you SilentHunter hello guys i have a project with Georgian calendar but when i contact to the developer they tell me we not support any other calendar so you must do this alone or get help from local developer. as manager i need to have basic knowledge from what is under my control. so please guide me to how change Georgian to Persian (jalali) calendar. i done translating from en to per but the most problem is the calendar. project address: https://drive.google.com/open?id=1eKestInuUiUJHotYltNuVsqRGnq4ujNN thank you for your attention and your kind best regards hi, does anyone have a way to take data from mysql and instert it into outlook or blackberry calendar? Hi There, I was wondering if there is a way, or in deed if there is an off the shelf calendar that would be able to interact with an SQL database? I want to be able to display a week's worth of dates (Mon - Fri) - and show what is on each day, for different people, say 4. If possible, I would like it to read start and end dates from the DB, and if that entry is over 3 days, display it on 3 calendar days. Has anyone heard of anything like this, or is it easy to code up? Thanks in advance Matt I am workin on a event calendar and i ran into a problem.. it shows the calendar and the today's date and 1 event on each month but i want it to show all the events for each month. my problem is i can't figure out how to loop it so it will.. here is where im having trouble at.. Code: [Select] for ($i=0; $i<($maxday+$startday); $i++) { if(($i % 7) == 0 ){ echo "<tr>"; } if($i < $startday){ echo ("<td bgcolor='414141'> </td>"); } else { if (($i - $startday + 1) == $today && $currentmonth == $cMonth && $currentyear == $cYear){ echo ("<td bgcolor='FF0000'><center><font color='FFFFFF'>".($i - $startday + 1)."</font></center></td>"); } else { [color=red]// this is where i need it to loop[/color] if (($i - $startday + 1) == $eday && $eMonth == $cMonth && $eYear == $cYear){ echo ("<td bgcolor='0000FF'><center><a class='info' href='#'><font color='FFFFFF'>".($i - $startday + 1)."<span>".$event."<hr><br>".$event_des."</span></font></a></center></td>"); } else { echo ("<td bgcolor='595959'><center><font color='FFFFFF'>".($i - $startday + 1)."</font></center></td>"); } } if(($i % 7) == 6 ) { echo "</tr>\n"; } } } i marked where the loop needs to go in red.. currently i have the sql query right above it in my script but i tried putting it where i need the loop and i get a error in there or it duplicates the calender and sometimes the numbers. can some please help me? Thank you Outsider_Child Hi, I'd really appreciate some guidance regarding the GET method. Thus far I've developed a calendar that displays a month at a time. I've created a 'next' button (div) that onclick - it submits values via GET. This works well. Code: [Select] <div onclick="location.href='cal.php?m=<?php if ($monthly == 12) { $monthly = 1; $yearly++; } else { $monthly++; } echo $monthly?>&y=<?php echo $yearly?>'" id="nextMonth" class="nextMonth next"></div> The complication comes with the 'prev' button, which I thought would be the reverse of the next button (logic wise). Code: [Select] <div onclick="location.href='cal.php?m=<?php if ($monthly == 1) { $monthly = 12; $yearly--; } else { $monthly--; } echo $monthly?>&y=<?php echo $yearly?>'" id="prevMonth" class="nextMonth prev"></div> Can you see any reason why this 'prev' button does not work? FYI, This reads GET and initiates the page Code: [Select] $m = !empty($_GET["m"]) ? $_GET["m"] : ''; $y = !empty($_GET["y"]) ? $_GET["y"] : ''; if ($m) { $monthly = ($m); $yearly = ($y); } else { $now = time(); $cur_month = date("n", $now); $cur_year = date("Y", $now); $monthly = $cur_month; $yearly = $cur_year; } Thanks. |