PHP - Calendar Help Arrays
Hi All,
I am writing a calendar code using Keith Devens PHP Calendar (version 2.3). What I am trying to acheive is this on one of my database tables I have a list of properties I have 41 property lists and each one has 2 sections for rates each section is named accordingly "a" for Jan for the first rate and "ma" for Jan for the second rate and there is 31 for each ie: a1 to a31 and ma1 to ma31 accordingly. At any given time there can be a rate in any one of these fields what I am trying to do is pull a 12 month view calendar on screen which show all these rates to the corresponding date on the calendar. The problem im having is with Keith Devens day Array() as ive never been too good with arrays. The code I have is pulling the data but only the first one it hits and I need to put them all into the array. I have included the code if someone can help I would appreciate it. <?php # PHP Calendar (version 2.3), written by Keith Devens # http://keithdevens.com/software/php_calendar # see example at http://keithdevens.com/weblog # License: http://keithdevens.com/software/license function generate_calendar($year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array()){ $first_of_month = gmmktime(0,0,0,$month,1,$year); #remember that mktime will automatically correct if invalid dates are entered # for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998 # this provides a built in "rounding" feature to generate_calendar() $day_names = array(); #generate all the day names according to the current locale for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday $day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month)); $weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day $title = htmlentities(ucfirst($month_name)).' '.$year; #note that some locales don't capitalize month and day names #Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03 @list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable if($p) $p = '<span class="calendar-prev">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> '; if($n) $n = ' <span class="calendar-next">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>'; $calendar = '<table class="calendar" border="1">'."\n". '<caption class="calendar-month">'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n."</caption>\n<tr>"; if($day_name_length){ #if the day names should be shown ($day_name_length > 0) #if day_name_length is >3, the full name of the day will be printed foreach($day_names as $d) $calendar .= '<th abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>'; $calendar .= "</tr>\n<tr>"; } if($weekday > 0) $calendar .= '<td colspan="'.$weekday.'"> </td>'; #initial 'empty' days for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){ if($weekday == 7){ $weekday = 0; #start a new week $calendar .= "</tr>\n<tr>"; } if(isset($days[$day]) and is_array($days[$day])){ @list($link, $content2) = $days[$day]; $content = $day; $calendar .= '<td>'. ($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).$content2.'</td>'; } else $calendar .= "<td>$day</td>"; } if($weekday != 7) $calendar .= '<td colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days return $calendar."</tr>\n</table>\n"; } function set($month, $year) { $days = array(); $kez = 1; $bef = 31; while($kez <= $bef) { $k2 = $kez; $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password mysql_connect("$host", "$username", "$password")or die("cannot connect"); if ($month == 1){$m = 'a'; $ma = 'ma';} if ($month == 2){$m = 'b'; $ma = 'mb';} if ($month == 3){$m = 'c'; $ma = 'mc';} if ($month == 4){$m = 'd'; $ma = 'md';} if ($month == 5){$m = 'e'; $ma = 'me';} if ($month == 6){$m = 'f'; $ma = 'mf';} if ($month == 7){$m = 'g'; $ma = 'mg';} if ($month == 8){$m = 'h'; $ma = 'mh';} if ($month == 9){$m = 'i'; $ma = 'mi';} if ($month == 10){$m = 'j'; $ma = 'mj';} if ($month == 11){$m = 'k'; $ma = 'mk';} if ($month == 12){$m = 'l'; $ma = 'ml';} $sql = "SELECT * FROM db213585521.property_list WHERE $m$k2 > 0 "; $q = @mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_array($q); $sql2 = "SELECT * FROM db213585521.property_list WHERE $ma$k2 > 0 "; $q2 = @mysql_query($sql2) or die(mysql_error()); $row2 = mysql_fetch_array($q2); if ($row[$m.$k2] > 0 || $row[$ma.$k2] > 0) { if ($row[$m.$k2] > 0){ $code = $row['var'].'<br>£'.$row[$m.$k2].'<br>'; }else{$code = '';} if ($row2[$ma.$k2] > 0){$code2 = $row2['var'].'<br>£'.$row2[$ma.$k2].'<br>';}else{$code2 ='';} if($k2 != 0) $days[$k2] = array('', $code.$code2); } $kez++; } setlocale(LC_TIME, 'en_GB'); echo generate_calendar($year, $month, $days, 3, NULL); } ?> <table style="margin: auto"> <tr> <?php for($month=1; $month<=12; $month++){ ?> <td style="vertical-align: top"> <?php set($month, date('Y')); ?> </td> <?php if($month%4 == 0 and $month<12){ ?> </tr><tr> <?php } ?> <?php } ?> </tr> </table> Similar TutorialsI have this thing that i am trying to make but i cant get it to work.. can anyone help? Code: [Select] function sql_read( $dbname,$dbusername,$dbpassword ) { $names = array(); $password = array(); $connect = @mysql_connect("mysql11.000webhost.com",$dbusername,$dbpassword) or die("Could Not Connect"); @mysql_select_db ($dbname) or die("Could not find DataBase"); $query = mysql_query("select * from users"); $numrows = mysql_num_rows($query); if ($numrows > 0){ while($row = mysql_fetch_assoc($query)){ $names[] = $row["uname"]; $password[] = $row["password"]; $id = $row["id"]; } $return = array($names,$password,$id); }else{ $return = array(); } return $return[]; } $names = array(); $names = sql_read("XXXXXX","XXXXXX","XXXXXXX")[0]; The error i get is Code: [Select] Parse error: syntax error, unexpected '[' in /home/a5480952/public_html/sql/index.php on line 28 Line 28 is "$names = sql_read("XXXXXX","XXXXXX","XXXXXXX")[0];" Please help... i REALLLLD need help with this.. ask questions if you want to know more about what i am trying to do... thanks! I'm having troubling with trying to create a function to spit out a single array with the following array. I can write it in a away that looks through the arrays manually. the results i am trying to generate is that each item in generated array. Array to convert array( "account" => array( "login", "register", "logout", "edit", ), "p" => array( "report", ), "array1.0" => array( "array2.0" => array( "array3.0", "array3.1 ), "array2.1", ), generating the array will look like this
Array ( [0] => account [1] => account/login [2] => account/register [3] => account/logout [4] => account/edit [5] => p [6] => p/report [7] => array1.0 [8] => array1.0/array2.0 [9] => array1.0/array2.0/array3.0 [10] => array1.0/array2.0/array3.1 [11] => array1.0/array2.1 ) The idea is that id generates a single array with combined labels and arrays inside, etc. I just can't figure out how to create a script that will create this array even If I add a new value or array.
I have two arrays, both with the same key values. I'd like to combine them. So for instance... Code: [Select] <?php $array1['abcd'] = array( 'value1' => "blah", 'value2' => "blahblah"); $array1['efgh'] = array( 'value1' => "ha", 'value2' => "haha", 'valuex' => "xyz"); $array2['abcd'] = array('value3' => "three", 'value4' => "four"); $array2['efgh'] = array( 'value3' => "hohoho", 'value6' => "six6"); function combine_arrays($array1,$array2) { //*combining* return $single_array; } echo "<pre>"; print_r(combine_arrays($array1,$array2)); echo "</pre>"; /* would produce ['abcd'] = ( 'value1' => "blah", 'value2' => "blahblah", 'value3' => "three", 'value4' => "four" ) ['efgh'] = ( 'value1' => "ha", 'value2' => "haha", 'valuex' => "xyz", 'value3' => "hohoho", 'value6' => "six6" ) */ ?> What's the easiest way to do this? 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 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? :\
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 hi, does anyone have a way to take data from mysql and instert it into outlook or blackberry calendar? 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 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 I am working with a site that needs some kind of calendar solution. Each user will have their own events calendar. The plan is that your events calendar could sync with google, ical, BB calendar when done. Should I build the calendar in PHP, then worry about syncing with these other apps? Or should I use come kind of 3rd party calendar to power the one I have? Or...does anyone know of any applications that help you sync calendars if I were to create one myself? I looked into google cals, but they have a limit on the amount of calendars per day you can create. Any ideas as to how I should go about this? All answers appreciated! 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. 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. 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 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 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 I'm trying to help someone out with their website (which is entirely in PHP) and I've come across a problem I can't seem to figure out. On the site is a php calendar that should display as so: However, sometimes for no apparent reason the calendar appears as so: I cannot seem to determine what is causing this to display incorrectly. It just started happening for no discernible reason. Anyone have any idea where I should start looking to find the issue? It is linked to a MySQL database that is somewhat wonky, could that be the issue? Thanks for any advice you guys can give me. 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! |