hi!
I would some advice or guidance to create a timetable or schedule like this.
the data i am pulling from my db are:
Begin and end time of courses, course names and day of the week.
Also I would like a notification of when 2 courses overlaps.

for example:

<table><tr>
<td>Monday</td>...
<td>Sunday</td>
</tr>
while or for each (day checks or time checks){<td></td>}
 </table>

Can anyone help?
thanks

Recommended Answers

All 11 Replies

Member Avatar for diafol

I recently created a bespoke system for scheduling with multiple users, see here:

http://www.daniweb.com/forums/thread226652.html

The attached zip file contains the pages and sql required. It's not brilliant, and was based on an 'old' timetable program of mine - back in the time when I was a real noob at php. You're welcome to download it and fiddle with it.

I recently created a bespoke system for scheduling with multiple users, see here:

http://www.daniweb.com/forums/thread226652.html

The attached zip file contains the pages and sql required. It's not brilliant, and was based on an 'old' timetable program of mine - back in the time when I was a real noob at php. You're welcome to download it and fiddle with it.

Hi! I did look at your php files b4 I even posted my question. I was a bit overwhelm by it since it does more than I require.
But I will take a look at it again and ask you any question I have.
will that be ok with you?

Member Avatar for diafol

Hi! I did look at your php files b4 I even posted my question. I was a bit overwhelm by it since it does more than I require.
But I will take a look at it again and ask you any question I have.
will that be ok with you?

No prob. If you just want a straight timetable, it's pretty simple:

TIMETABLE
id
start_datetime
end_datetime
title
description
schedule_type (this can set a colour etc)

To avoid making clashes, just check your proposed start and end times against the db for overlaps. Here's some pseudocode:

if
1) proposed start_datetime OR end_datetime is between start_datetimes and end_datetimes in the db - raise a warning
2) proposed start_datetime < db start_datetimes AND proposed end_datetime > db end_datetimes - raise a warning
else
add record to the db

Hope that more helpful.

i have tried doin the following code. (i only did for Monday). the output is shown in 'schedule.jpg'. However i would like the output to be like 'schedule ideally.jpg'.
what I am doing wrong?

<table width="800" border="1">
  <tr>
    <td>TIME</td>
    <td>Monday</td>
    <td>Tuesday</td>
    <td>Wednesday</td>
    <td>Thursday</td>
    <td>Friday</td>
    <td>Saturday</td>
    <td>Sunday</td>
  </tr>

 

  <?php 
$query4= "select COURSEOFFERING.DAY , COURSEOFFERING.BEGINTIME , COURSEOFFERING.ENDTIME , COURSEOFFERING.STATUS  ,COURSEAPP.CAID, COURSEAPP.COID , COURSEAPP.APPLICATIONID  , COURSEOFFERING.COST , COURSEOFFERING.COID, COURSEOFFERING.COURSEID ,COURSE.COURSEID, COURSE.TITLE from courseapp, COURSEOFFERING , COURSE where COURSEAPP.APPLICATIONID =".$appidcheck." and COURSEAPP.COID= COURSEOFFERING.COID and COURSEOFFERING.COURSEID= COURSE.COURSEID order by COURSEOFFERING.BEGINTIME asc";
$result4 = mysql_query($query4);
while($row=mysql_fetch_array($result4)){ 

if($row['DAY']=="Monday"){

echo"<tr>  <td>7:45</td>";
if($row['BEGINTIME']>= "07:45:00" && $row['BEGINTIME']<= "07:59:00"){
echo  "<td>".$row['TITLE']."<br>".$row['BEGINTIME']." - ".$row['ENDTIME']."</td>"; }
if($row['ENDTIME']>= "08:00:00" && $row['ENDTIME']<= "08:14:00"){
echo "</tr>";}

echo"<tr>  <td>8:00</td>";
if($row['BEGINTIME']>= "08:00:00" && $row['BEGINTIME']<= "08:14:00"){
echo  "<td>".$row['TITLE']."<br>".$row['BEGINTIME']." - ".$row['ENDTIME']."</td>"; }
if($row['ENDTIME']>= "08:15:00" && $row['ENDTIME']<= "08:29:00"){
echo "</tr>";}

echo"<tr>  <td>8:15</td>";
if($row['BEGINTIME']>= "08:15:00" && $row['BEGINTIME']<= "08:29:00"){
echo  "<td>".$row['TITLE']."<br>".$row['BEGINTIME']." - ".$row['ENDTIME']."</td>"; }
if($row['ENDTIME']>= "08:30:00" && $row['ENDTIME']<= "08:44:00"){
echo "</tr>";}


echo"<tr>  <td>8:30</td>";
if($row['BEGINTIME']>= "08:30:00" && $row['BEGINTIME']<= "08:44:00"){
echo  "<td>".$row['TITLE']."<br>".$row['BEGINTIME']." - ".$row['ENDTIME']."</td>"; }
if($row['ENDTIME']>= "08:45:00" && $row['ENDTIME']<= "08:59:00"){
echo "</tr>";}


echo"<tr>  <td>8:45</td>";
if($row['BEGINTIME']>= "08:45:00" && $row['BEGINTIME']<= "08:59:00"){
echo  "<td>".$row['TITLE']."<br>".$row['BEGINTIME']." - ".$row['ENDTIME']."</td>"; }
if($row['ENDTIME']>= "09:00:00" && $row['ENDTIME']<= "09:14:00"){
echo "</tr>";}

echo"<tr>  <td>9:00</td>";
if($row['BEGINTIME']>= "09:00:00" && $row['BEGINTIME']<= "09:14:00"){
echo  "<td>".$row['TITLE']."<br>".$row['BEGINTIME']." - ".$row['ENDTIME']."</td>"; }
if($row['ENDTIME']>= "09:15:00" && $row['ENDTIME']<= "09:29:00"){
echo "</tr>";}

echo"<tr>  <td>9:15</td>";
if($row['BEGINTIME']>= "09:15:00" && $row['BEGINTIME']<= "09:29:00"){
echo  "<td>".$row['TITLE']."<br>".$row['BEGINTIME']." - ".$row['ENDTIME']."</td>"; }
if($row['ENDTIME']>= "09:30:00" && $row['ENDTIME']<= "09:44:00"){
echo "</tr>";}


echo"<tr>  <td>9:30</td>";
if($row['BEGINTIME']>= "09:30:00" && $row['BEGINTIME']<= "09:44:00"){
echo  "<td>".$row['TITLE']."<br>".$row['BEGINTIME']." - ".$row['ENDTIME']."</td>"; }
if($row['ENDTIME']>= "09:45:00" && $row['ENDTIME']<= "09:59:00"){
echo "</tr>";}



}//monday




else{echo  "<td></td>"; }
Member Avatar for diafol

OK, before anything else - are courses allowed to overlap?

yes courses can overlap, but a notification must pop up (by any method)

I am encountering a problem, by which when I escape the while loop via "continue". the table times are re- generated starting over from 8:00 as shown in figure 1

is there a way to escape the loop and continue from the begin time of the next topic? or is the table algorithm needs to be redone, if yes, guidance is needed.
I would like the output to be as shown in figure2

FIGURE 1
[IMG]http://i45.tinypic.com/f1a908.jpg[/IMG]
Figure 2
[IMG]http://i48.tinypic.com/2ldgm7b.jpg[/IMG]

$rowspan=0; 
$result4 = mysql_query($query4);
while($row=mysql_fetch_array($result4)){ 

if($row['DAY']=="Monday"){
// a START time value
$start = $row['BEGINTIME'];
// an END time value
$end   = $row['ENDTIME'];

// what is the time difference between $end and $start?
if( $diff=@get_time_difference($start, $end) ){
$row_calc= sprintf( $diff['rowvalue']);}
else{  echo "Hours: Error";}

$rowspan = $row_calc +1 ; 
$row_attr="rowspan=\"".$rowspan."\"";

echo "  </tr>";
echo"<tr>  <td>8:00</td>";
if($row['BEGINTIME']>= "08:00:00" && $row['BEGINTIME']<= "08:14:00"){
echo  "<td ".$row_attr.">".$row['TITLE']."<br>".$row['BEGINTIME']." - ".$row['ENDTIME']."</td>"; }
if($row['ENDTIME']>= "08:15:00" && $row['ENDTIME']<= "08:29:00"){
continue;} 


echo"<tr>  <td>8:15</td>";
if($row['BEGINTIME']>= "08:15:00" && $row['BEGINTIME']<= "08:29:00"){
echo  "<td ".$row_attr.">".$row['TITLE']."<br>".$row['BEGINTIME']." - ".$row['ENDTIME']."</td>"; }
if($row['ENDTIME']>= "08:30:00" && $row['ENDTIME']<= "08:44:00"){
continue;} 


echo"<tr>  <td>8:30</td>";
if($row['BEGINTIME']>= "08:30:00" && $row['BEGINTIME']<= "08:44:00"){
echo  "<td ".$row_attr.">".$row['TITLE']."<br>".$row['BEGINTIME']." - ".$row['ENDTIME']."</td>"; }
if($row['ENDTIME']>= "08:45:00" && $row['ENDTIME']<= "08:59:00"){
continue;} 



echo "</tr>"; 
}//monday

}//while

hi
can ı ask something about this code?...especially, you attached figures of these. I wonder Database's and ı tried but it does not work.and ı have a graduation project related this topic..could you help me? could you sent database program of these figures...thanks a lot

hi
can ı ask something about this code?...especially, you attached figures of these. I wonder Database's and ı tried but it does not work.and ı have a graduation project related this topic..could you help me? could you sent database program of these figures...thanks a lot

I still have not figured this issue as yet, I am seeking other assistance.
will post if any progress is made.

I still have not figured this issue as yet, I am seeking other assistance.
will post if any progress is made.

I have tried also someting on your program because I have something similar to that codes but simple one than yours... but I wonder all of program's code..can you send me your code with database system codes..if I can manage to solve your problem , I will send you back the compilable one.
can you send me detailed codes to my e-mail
( tugbagul52@gmail.com) with compressed one ( database of system and php code). because I confused and I could not make it to work your program..I did not see as attached on figures that you have put on form...I have seen your program codes on Dev Shed forums website regarding some problems I couldn't send this message from that web site so I send message again from here...thanks

Hi humeyra:
it has been a long time since the first post.
Just wanted to let you know we ended up hiring someone to solve this issue, but I do not own the code so I cannot publish it. but thanks for your interest.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.