?
Solved

Create daily calendar with PHP/HTML/CSS

Posted on 2014-09-09
2
Medium Priority
?
596 Views
Last Modified: 2014-09-16
I created a day by day calendar broken down in 15 minute increments throughout the day ... now I need to figure out how to property populate the calendar for the events (so for example if an event is 2 hours from 9am to 11am that it is shown properly across the respective rows ....

Here's what I have so far:
<?php

require('library.php');

$start_time = '8:00 AM';
$end_time = '10:00 PM';
$minutes_breakage = '15';

$day = getvar('day');
if(strlen($day)<1) $day = date('m/d/Y');
else { $day = date('m/d/Y', strtotime($day)); }

$inc   = $minutes_breakage * 60;
$start = (strtotime($start_time)); // 6  AM
$end   = (strtotime($end_time)); // 10 PM

echo "<h3>Day: $day</h3>";

echo <<< HTML
<style>
/* TEST */
.id_33__08_00_AM {
	background-color: green;
}
</style>
HTML;

echo '<table border=1 cellspacing=0><tr><td>Time</td>';
	
foreach (getrows("SELECT * FROM users WHERE type='Agent' AND active='Yes'") AS $row) {
	echo "<td>{$row['full_name']}</td>";
	$usercols .= "<td class='id_{$row['user_id']}__[TIMESTART]'></td>";
}

echo '</tr>';

for( $i = $start; $i <= $end; $i += $inc ) {
    #$range = date( 'g:i', $i ) . ' - ' . date( 'g:i A', $i + $inc );
	$show = date( 'g:i A', $i );
	$csstime = date('h_i_A', $i);
	$myusercols = str_replace('[TIMESTART]', $csstime, $usercols);
	echo "<tr><td>$show</td>$myusercols</tr>";
}
echo '</table>';


?>

Open in new window


I was playing around with CSS but apparently you cannot do rowspans with it and if I define a rowspan on a td say beginning at 9AM, I need to make sure a <td> tag does not appear anywhere where the rowspan is supposed to span across. I need an example of the best way of structuring the php code to properly populate the daily calendar with events that span across the events hours.. (I know how to pull it from MySQL/etc but I need to know how to output it so it appears properly)
0
Comment
Question by:Mark
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 40313155
Can you please share a mockup of what you want the calendar to look like, along with the test data that would be used to create the HTML document that looks like the mockup?  Can you please post the CREATE TABLE statement for the 'users' table and any other tables that are in play?  Thanks!
0
 

Author Comment

by:Mark
ID: 40326460
I figured it out...

$minutesinappt = getcol("SELECT TIMESTAMPDIFF(MINUTE,`start_time`,`end_time`) FROM appointments WHERE id='{$appointment['id']}' AND cancelled != 1");
$cycles = $minutesinappt/$minutes_breakage;
		
		if($cycles==1) {
			echo "<td>Appointment With {$appointment['client']}</td>";
		}
		
		else if(!isset($appointmentrowsleft[$apptid])) {
			$appointmentrowsleft[$apptid] = 1;
			echo "<td rowspan='$cycles'>Appointment With {$appointment['client']}</td>";
		}
		......

Open in new window

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question