PHP - Php Mysql Calendar With A Twist
Hi Guys, first time poster, so I hope I have it in the right category. I've used a program called Training Peaks for years, great program and it does cost a few $$'s. I'm also going through the Php MySQL learning curve and thought why not build something basic that I could use rather than TP. I've been dabbling with php/mysql for a few years, nothing serious and have been looking at a few core calendar codes like Ajax, Lavarel and one built on html5. I was curious with your knowledge what might be the best way to look at this project (attachment). In a nut shell the option to create a session (training session) it this case, it for Triathlon (swim, bike & run) ability to set a session time, date, distance and maybe some notes. TP has a lot more data that feeds from Garmin data, that's a bit over my head at the moment, so ignore TSS IF's etc The attachment is the calendar in the back ground with the individual session open, again a lot more data there than what I need. Google calendar was an option, but why not make it fun and learn something! Thanks in advance.
Similar Tutorialshi, does anyone have a way to take data from mysql and instert it into outlook or blackberry calendar? Has anyone done this before? i have the following VERY basic looking calendar to display the current month and <strong> on the current date; <?php /* Set the default timezone */ date_default_timezone_set("Europe/London"); /* Set the date */ $date = strtotime(date("Y-m-d")); $day = date('d', $date); $month = date('m', $date); $year = date('Y', $date); $firstDay = mktime(0,0,0,$month, 1, $year); $title = strftime('%B', $firstDay); $dayOfWeek = date('D', $firstDay); $daysInMonth = cal_days_in_month(0, $month, $year); /* Get the name of the week days */ $timestamp = strtotime('next Sunday'); $weekDays = array(); for ($i = 0; $i < 7; $i++) { $weekDays[] = strftime('%a', $timestamp); $timestamp = strtotime('+1 day', $timestamp); } $blank = date('w', strtotime("{$year}-{$month}-01")); ?> <table class='cal-table cal-table-bordered' border=1 style='table-layout: fixed;'> <tr> <th colspan='7' class='cal-text-center'> <?php echo $title ?> <?php echo $year ?> </th> </tr> <tr> <?php foreach($weekDays as $key => $weekDay) : ?> <td class='cal-text-center"'><?php echo $weekDay ?></td> <?php endforeach ?> </tr> <tr class='cal-row'> <?php for($i = 0; $i < $blank; $i++): ?> <td></td> <?php endfor; ?> <?php for($i = 1; $i <= $daysInMonth; $i++): ?> <?php if($day == $i): ?> <?php //database code here ?> <td><strong><?php echo $i ?></strong></td> <?php else: ?> <td><?php echo $i ?></td> <?php endif; ?> <?php if(($i + $blank) % 7 == 0): ?> </tr><tr class='cal-row'> <?php endif; ?> <?php endfor; ?> <?php for($i = 0; ($i + $blank + $daysInMonth) % 7 != 0; $i++): ?> <td></td> <?php endfor; ?> </tr> </table> how can i get data into this calendar from my 'events' table, to perhaps highlight the date of the event and show a hidden <DIV> when rollover. i have columns: 'eventStart' and 'eventEnd' and 'eventName' in the 'events' table. or shall i look for something else? this has to be super simple with no backend or multiple files being used etc..
thanks I am trying to create a calendar of Events for my company's website. When I search for this type of calendar, I can find code that runs the calendar from one Events table. However, we could have an Event that has multiple performances. (For example, Lily Tomlin could be performing at the Atwood Concert Hall in Anchorage on 09/09/11 and at the Vagabond Blues in Palmer on 09/10/11.) So we have two tables to draw the information from: Events and Performance I can successfully create a MySQL query (see below) with PHP coding that will make a listing (as demostrated on our website http://www.centertix.net/). Code: [Select] "SELECT Events.PublishDate, Events.EventOnSaleDate, Events.BldgContractDate, Events.SetUpComplete, Events.EventTitle, Performance.PerfID, Performance.startDateTime, Performance.endDateTime, Performance.PerfType, venues.VenueName, venues.VenueCode FROM (Performance RIGHT JOIN Events ON Performance.EventID = Events.EventID) LEFT JOIN venues ON Performance.VenueCode = venues.VenueCode WHERE Events.BldgContractDate Is Not Null AND Events.SetUpComplete Is Not Null AND Performance.PerfType='Public Event'"However, I'm not advanced enough to create the if-clause or while-loop to check to see if the Performance.startDate = the calendar's date and then place the info into the appropriate calendar grid box. I think have determined where it should be place in my PHP code, but need help getting the calendar to work. Here's the code where I think it should go: Code: [Select] for($list_day = 1; $list_day <= $days_in_month; $list_day++): if(($list_day == date("j",mktime(0,0,0,$this->month))) && (date("F") == date("F",mktime(0,0,0,$this->month))) && (date("Y") == date("Y",mktime(0,0,0,$this->month,$list_day,$this->year)))) { $this->calendar.= '<td class="'. $this->style .'-current-day">'; } else { if(($running_day == "0") || ($running_day == "6")) { $this->calendar.= '<td class="'. $this->style .'-weekend-day">'; } else { $this->calendar.= '<td class="'. $this->style .'-day">'; } } /* add in the day number */ $this->calendar.= '<div class="'. $this->style .'-day-number">'.$list_day.'</div>'; /** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !! IF MATCHES FOUND, PRINT THEM !! **/ $this->calendar.= '<div class="'. $this->style .'-text"><a href="">PERFORMANCE INFO</a></div>'. "\n"; /** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !! IF NO MATCHES FOUND, PRINT NOTHING !! **/ $this->calendar.= str_repeat('<p> </p>',2); $this->calendar.= '</td>'; if($running_day == 6): $this->calendar.= '</tr>'; if(($day_counter+1) != $days_in_month): $this->calendar.= '<tr class="'. $this->style .'-row">'; endif; $running_day = -1; $days_in_this_week = 0; endif; $days_in_this_week++; $running_day++; $day_counter++; endfor; Please help me plug the calendar in with the appropriate events! If you would like to see how far I have gotten, you can check out this link: http://www.myalaskacenter.com/calendars/calendarSample2.php Hello Code Gents, I get so stretched breaking point when a trusted resuable code refuses to perform: Here's it Code: [Select] <?php require_once("includes/start_session.php"); require_once("includes/cn.php"); $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $username=$_GET[$_SESSION['username']]; require_once("includes/nav_menu.php"); ///updates $msg=""; $aid=$_GET['aid']; $staff_id=$_GET['staff_id']; $come="select * from staff_payrolls where staff_id='$staff_id'"; $q1=mysqli_query($dbc,$come); $row=mysqli_fetch_array($q1); $aid = $row['aid']; $staff_id = $row['staff_id']; $basic = $row['basic']; $rent = $row['rent']; $pension = $row['pension']; $union = $row['union']; $tax = $row['tax']; $net = $row['net']; $gross = $row['gross']; if (isset($_POST['submit'])) { $renti=$basic*0.5; $pensioni=$basic*0.05; $unioni=$basic*0.03; $taxi=$basic*0.02; $neti=$basic+$rent; $grossi=$basic+$rent+$pension+$tax; // Grab the profile data from the POST //$staff_id = mysqli_real_escape_string($dbc, trim($_POST['staff_id'])); $basic = mysqli_real_escape_string($dbc, trim($_POST['basic'])); $rent = mysqli_real_escape_string($dbc, trim($_POST['rent'])); $union = mysqli_real_escape_string($dbc, trim($_POST['union'])); $pension = mysqli_real_escape_string($dbc, trim($_POST['pension'])); $tax = mysqli_real_escape_string($dbc, trim($_POST['tax'])); $net = mysqli_real_escape_string($dbc, trim($_POST['net'])); $gross = mysqli_real_escape_string($dbc, trim($_POST['gross'])); $error=false; if (!$error) { if (!empty($aid)) { //UPDATE `ak`.`staff_payrolls` SET `basic` = '' WHERE `staff_payrolls`.`aid` =1; $sql= "UPDATE `ak`.`staff_payrolls` SET `basic` ='$_POST[basic]', `rent`='$renti',`pension`='$pensioni',`union`='$unioni',`tax`='$taxi',`net` ='$neti',`gross` ='$grossi',`salary_date`=SYSDATE() where `staff_payrolls`.`aid` ='$aid'"; mysqli_query($dbc, $sql); } } // End of check for form submission } ?> <p><strong>Welcome to BODE COSMETICS PAYROLL MANAGEMENT SYSTEM.</strong></p> <p><?php echo("Welcome $_SESSION[username]. You can start by the top-pane Navigation") ;?> <p><?php //echo $err ; if (@mysqli_query($dbc, $sql)) { echo 'Record Updated';} $query = "SELECT * FROM staff_payrolls WHERE aid = '$aid'"; $data = mysqli_query($dbc, $query); $row = mysqli_fetch_array($data); $staff_id = $row['staff_id']; $basic = $row['basic']; $rent = $row['rent']; $pension = $row['pension']; $union = $row['union']; $tax = $row['tax']; $net = $row['net']; $gross = $row['gross']; ?> <table> <form name="login" method="post" action=""> <tr> <td> <th scope="col"><strong>STAFF UPDATE AREA</strong></th> </td> </tr> <tr> <td> STAFF ID <th scope="col"><input name="staff_id" type="text" value="<?php echo $row['staff_id']; ?>" disabled="disabled" /></th> </td> </tr> <tr> <td> BASIC SALARY<th scope="col"><input name="basic" type="text" value="<?php echo $row['basic']; ?>" /></th> </td> </tr> <tr> <td> RENT <th scope="col"><input name="rent" type="text" value="<?php echo $rent; ?>" /></th> </td> </tr> <tr> <td> PENSION <th scope="col"><input name="pension" type="text" value="<?php echo $pension; ?>" /></th> </td> </tr> <tr> <td> UNION <th scope="col"><input name="union" type="text" value="<?php echo $union; ?>" /></th> </td> </tr> <tr> <td> TAX <th scope="col"><input name="tax" type="text" value="<?php echo $tax; ?>" /></th> </td> </tr> <tr> <td> NET <th scope="col"><input name="net" type="text" value="<?php echo $net; ?>" /></th> </td> </tr> <tr> <td> GROSS <th scope="col"><input name="gross" type="text" value="<?php echo $gross; ?>" /></th> </td> </tr> <tr> <td> <th scope="col"><input name="submit" type="submit" value="Update_Salary" /></th> </td> </tr> </form> </table> </p> </div> <div class="footer"></div> </div> <div class="post"> <div class="header"> <?php require_once("includes/footer.php");?> The funny thing now is that when I press the submit button, nothing happens. Except for the display of what is in the database. I'm looking for a random number generator, that chooses a number every hour, and when it does it will be out of 100 (these are player ID's) once the number is chosen, I would like 10 Crystals (special payment) to be given to the number (ID). Is this possible and if so, please help. This is all I have (generator) function createRandomAGTNO() { do { $agt_no = mt_rand(1,100); $valid = true; if (preg_match('/(\d)\1\1/', $agt_no)) $valid = false; // Same digit three times consecutively elseif (preg_match('/(\d).*?\1.*?\1.*?\1/', $agt_no)) $valid = false; // Same digit four times in string } while ($valid === false); return $agt_no; } Please reply ASAP? 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? :\ 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... I am working on a small project, creating a calendar based booking system which includes the following features: 1) A color coded key for Booked days, Available, Partly Booked, Off Days 2) Clickable days which open up a form with available time slots 3) When time slots selected another form which allows the user to enter details about the event and then book the day
I am using php, sql to complete the project. I am aware that there are scripts available online but i want to do this from scratch.
Stuck On The code below is for a php calendar, above is what i need to achieve. Please can someone help me on how to complete this. <?php $monthNames = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); ?> <?php if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n"); if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y"); ?> <?php $cMonth = $_REQUEST["month"]; $cYear = $_REQUEST["year"]; $prev_year = $cYear; $next_year = $cYear; $prev_month = $cMonth-1; $next_month = $cMonth+1; if ($prev_month == 0 ) { $prev_month = 12; $prev_year = $cYear - 1; } if ($next_month == 13 ) { $next_month = 1; $next_year = $cYear + 1; } ?> <table width="400" border="5" align="center"> <tr align="center"> <td bgcolor="#999999" style="color:#FFFFFF"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="50%" align="left"> <a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $prev_month . "&year=" . $prev_year; ?>" style="color:#FFFFFF">Previous</a></td> <td width="50%" align="right"><a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $next_month . "&year=" . $next_year; ?>" style="color:#FFFFFF">Next</a> </td> </tr> </table> </td> </tr> <tr> <td align="center"> <table width="100%" border="2" cellpadding="2" cellspacing="2"> <tr align="center"> <td colspan="7" bgcolor="#999999" style="color:#FFFFFF"> <strong> <?php echo $monthNames[$cMonth-1].' '.$cYear; ?> </strong> </td> </tr> <tr> <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>S</strong></td> <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>M</strong></td> <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>T</strong></td> <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>W</strong></td> <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>T</strong></td> <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>F</strong></td> <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>S</strong></td> </tr> <?php $timestamp = mktime(0,0,0,$cMonth,1,$cYear); $maxday = date("t",$timestamp); $thismonth = getdate ($timestamp); $startday = $thismonth['wday']; for ($i=0; $i<($maxday+$startday); $i++) { if(($i % 7) == 0 ) echo "<tr> "; if($i < $startday) echo "<td></td> "; else echo "<td align='center' valign='middle' height='20px'>". ($i - $startday + 1) . "</td> "; if(($i % 7) == 6 ) echo "</tr> "; } ?> </table> </td> </tr> </table> 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 hello all, i currently have a daily log book that the employees fill out. the logs are displayed in a list format. would there be an easy way to have an actual calendar look and have any logs for the day have the title display? i can probably take care of the output on each day, just dont know how to have a calendar display. thanks I have a calendar with a month view. I can click on a date to add or edit an event. The current date is coloured red. I made sure that when I click on next to go to the next month the day is not coloured red. However when I am in a month, not being the current month I CANNOT click on the day of today. So if I would like to click on 21 July or 21 September this is not possible. I have tried everything but it doesn't change anything. Code: [Select] <?php $i = 0; while (list(, $week) = each($weeks)) { echo "<tr class='mainrow'>\n"; while (list(, $d) = each($week)){ if($i < $offset_count){ //$day_link = "<a href=\"".$_SERVER['PHP_SELF']."?date=".mktime(0, 0, 0, $month -1, $d, $year)."\">$d</a>"; echo "<td class=\"nonmonthdays\">$day_link</td>\n"; } if(($i >= $offset_count) && ($i < ($num_weeks * 7) - $outset)){ $datecount=mktime(0, 0, 0, $month -1, $d, $year); $short = ''; //$day_link = $d; $day_link = "<A href=\"javascript:popWin('editcalendar.php?ID=$datecount', 450, 570)\">$d</a>"; $query = "SELECT * FROM bl_calender WHERE viewable='1'"; $r = mysql_query ($query) or die ("Query error: ".mysql_error()); while($row=mysql_fetch_array($r)) {//Array or records stored in $row if($row['dateclass']==$datecount) { $short = $row['short']; $day_link = "<A href=\"javascript:popWin('editcalendar.php?ID=$datecount', 450, 570)\" title=\"$short\"><FONT style='BACKGROUND-COLOR: yellow'><b>$d </b></font></a>";} } $this_month = date('M'); if($date == mktime(0, 0, 0, $month, $d, $year)){ if($this_month == $month_name) { // only make date red if it is current month echo "<td><A href=\"javascript:popWin('editcalendar.php?ID=$datecount', 450, 570)\" title=\"$short\"><font color='red'><b>$d</b></font></a></td>\n"; } else {echo "<td><A href=\"javascript:popWin('editcalendar.php?ID=$datecount', 450, 570)\" title=\"$short\"><a style='color:#0066FF'>$d</a></td>\n"; } } else { echo "<td class=\"days\">$day_link</td>\n"; } } elseif(($outset > 0)) { if(($i >= ($num_weeks * 7) - $outset)){ $day_link = ""; echo "<td class=\"nonmonthdays\">$day_link</td>\n"; } } $i++; } echo "</tr>\n"; } // Close out your table and that's it! echo "<tr class='headline'><td colspan='7' class='days'> </td></tr>"; echo '</table>'; ?> hi i open this post so i dont open 5 new ones ok i have a task to do an event calendar now i found some tutorial for creating simple calendar BUT all of them are on english what i need is change it to croatian - that means i have custom names for days, custom names for months, and what i also need is put sunday where it belongs... at the end because we are calculating week starts by monday... so any tips? if you know some tutorial that works for these spec things i googled it but i only found like 2 calendars that actualy works other have some bugs in scripts and wont do thing or just write me tips and ill try to create it Can anyone help me please, I am trying to place a PHP calendar into an existing DIV tag that used to hold a flash slideshow application, but we want to replace that with a calendar. Here is my code: Code: [Select] echo '<div class="grid_9"> <div class="box"> <h2>'.$titleone.'</h2> <div class="block">'; if (!defined('BLOCK_FILE')) { Header('Location: ../index.php'); die(); } $modName = 'GCalendar'; $blockConfig = array('maxTitle' => 21, 'eventPrefix' => '• ', 'maxEvents' => 10, 'lookahead' => 2, 'twoColumn' => false, 'excludeCats' => array(), 'force_center' => false, ); require_once 'modules/' . $modName . '/language.php'; gcalGetLang($modName); require_once 'modules/' . $modName . '/gcal.inc.php'; require_once 'modules/' . $modName . '/common.inc.php'; require_once 'modules/' . $modName . '/getMonthlyEvents.php'; require_once 'modules/' . $modName . '/gcalBlock.php'; $config = getConfig(); list($year, $month, $today) = explode(',', date('Y,n,j')); $block = new GCalBlock($year, $month, $today, $config, $blockConfig); $content = $block->calendar(); $content .= '<br />'; $content .= $block->upcomingEvents(); echo '</div> </div> </div>'; When I try this above, I just get an 'Too many page loads' error, so I'm not sure what I've done wrong. Any help appreciated. Regards, Tree This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=347993.0 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. Good Evening, I have a working knowledge or HTML/CSS and right now I am learning/reading about PHP. Currently I am looking to build a website around an events calendar, let me explain more. A user would log onto the site, submit a form (with an event), this would then be added to a calendar as well a new page for the event details. The calendar would be fully visible to an visitor to the site. I would also like the ability to add a ticker on the homepage with the latest events added. How complicated is this to implement? And what are the basic requirements? I hope this makes sense. Thanks, Cain 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. |