Hi Folks,
I am new to the forum and therefore a short introduction. I am a Multimedia Artist and therefore my knowledge is partially first class and in other parts it is to cry over. Since I am heavily working on projects it seems always only time to deal with a specific problem rather than basic knowledge. Thus, sometimes might a question seem somewhat really rookielike.
So hi everybody![]()
My specific problem at hand is as follows: For my own clients using a not multimedia related service, I created a calender system. Most of the calendar is completed but there is still a rather peculiar problem.
In case a person for example visits a Symposium lasting several days, the Symposium consisting of several workshops the calendar owner might light to visit, the calendar shall allow appointment collisions.
The appointments are in a mySQL database. The code to retreive the data is quite simple:
The second part important to the problem is my CSS. It consists ofPHP Code:$query = mysql_query("SELECT * FROM $App
WHERE userID LIKE '{$_SESSION['userID']}'
AND appDateStart LIKE '$userTermin' ");
$result = mysql_num_rows($query);
$felder = mysql_num_fields($query);
if(! $query) {die("Fehler bei Query $query"); }
for($i=0; $i<$result; $i++) {
$data[$i] = mysql_fetch_array($query);
HTML Code:<style> #tag { position: relative; height: 400px; width: 450px; border: 1px solid #DDD; } #termins { font: 12px Arial; position: absolute; height: 400px; width: 350px; left: 55px; line-height: 16px; } #zeit { font: 12px Arial; position: absolute; height: 400px; width: 50px; line-height: 16px; } </style> <div id='tag'> <div id='zeit'> <b>Zeit</b> <br /> 08:00 <br /> 08:30 <br /> 09:00 <br /> 09:30 <br /> 10:00 <br /> 10:30 <br /> 11:00 <br /> 11:30 <br /> 12:00 <br /> 12:30 <br /> 13:00 <br /> 13:30 <br /> 14:00 <br /> 14:30 <br /> 15:00 <br /> 15:30 <br /> 16:00 <br /> 16:30 <br /> 17:00 <br /> 17:30 <br /> 18:00 <br /> 18:30 <br /> 19:00 <br /> 19:30 <br /> </div> <div id='termins'> HERE ARE THE #termins DIVS --> Each #termins IS ONE APPOINTMENT </div>
The #termins are placed with absolute positioning as follows:
The Variables are set as follows:HTML Code:<div id='terminx' style='position: absolute; border: 1px solid red; top: " . $_top[$i] . "px; left: " . $_left[$i] . "px; width: " . $_width[$i] . "px; height: " . $_height[$i] . "px; '>
Until here, everything works perfect.PHP Code:$round_numerator = 15;
$_minuteStart[$i] = date('i', strtotime($data[$i]['appTimeStart']));
$_StartMin[$i] = ( round ( $_minuteStart[$i] / $round_numerator ) * $round_numerator );
if ($_StartMin[$i] == '00') { $_minitStart[$i] = 0; }
elseif ($_StartMin[$i] == '15') { $_minitStart[$i] = 8; }
elseif ($_StartMin[$i] == '30') { $_minitStart[$i] = 16; }
elseif ($_StartMin[$i] == '45') { $_minitStart[$i] = 24; }
$_stunde[$i] = date('H', strtotime($data[$i]['appTimeStart']));
$_top[$i] = 16 + ($_stunde[$i]-8)*32 + $_minitStart[$i];
// --- BERECHNUNG HEIGHT --------------------------------------
$_minuteEnd[$i] = date('i', strtotime($data[$i]['appTimeEnd']));
$_EndMin = ( round ( $_minuteEnd[$i] / $round_numerator ) * $round_numerator );
if ($_EndMin[$i] = 0) { $_minitEnd[$i] = 0; }
elseif ($_EndMin[$i] = 15) { $_minitEnd[$i] = 8; }
elseif ($_EndMin[$i] = 30) { $_minitEnd[$i] = 16; }
elseif ($_EndMin[$i] = 45) { $_minitEnd[$i] = 24; }
$_stundeEnd[$i] = date('H', strtotime($data[$i]['appTimeEnd']));
$_endzeit[$i] = 16 + ($_stundeEnd[$i]-8)*32 + $_minitEnd[$i];
$_height[$i] = $_endzeit[$i] - $_top[$i];
The heights are set, the top_position is placed exactly beneath the respective time. But the setting of $_width and the question of the collision is the problem.
How can I ask in PHP, which appointments collide? I tried already several if-variations, but it seems I will only get the message colliding with another one, but not the original message it is collding with.
I get several values: 9 collides with 1, 1 collides with 2, 2 collides with 9. In reality, all three collide. How can I ask for that?
When doing above solution, I need absolute control over the width and the placement ($_left) to avoid overlapping appointment views.
Has anyone another idea, how I could work here? I am open to any suggestions. Maybe, I am handling the baby from the wrong side. Any ideas or help is welcome.
Yours, Sunny



Bookmarks