assgar 14 Junior Poster in Training

Hi

I need help.

I know what I want to accomplish, but I do not know how to do it.

The events are recurring every month, but not recurring at the same time or on the
same day of the week.


WHAT I NEED HELP ACCOMPLISHING:
How to do I insert recurring events into a table for a date range.
Where the months are the same but the event/appointment types occur at different
times and or on different days of the week.


POSSIBLE APPROACH:
I would like to choose a 7 day cycle/template, or to allow making the weeks
different with a 14 day or 21 day or 28 day cycle/template.

For example the 14 days cycle represents two weeks where every second week can be
different.

Day# Day
1
2 Monday (meetings 1:00pm to 3:00pm)
3 Tuesday
4 Wednesday
5 Thursday (breakfast meeting 8:00AM to 9:00AM)
6 Friday
7
8
9 Monday (breakfast meeting 8:00AM to 9:00AM)
10 Tuesday
11 Wednesday (meetings 1:00pm to 3:00pm)
12 Thursday
13 Friday
14


The current code works well for a week or if every week is the same in the date range.
See below.

The availablity table store different event/appointment types using date and time range.
This event/appointment type information is then displayed to the user using a daily
schedule format.

HOW THE 7 DAY CYCLE DATA IS STORED:
Example: Meetings(event_type_code) between 2:30 PM and 4:30 PM for Monday to Friday
this is stored in the "availablity" table as seen below.

Note: A template group holds the different appointment types for the days of the
week as selected.

|group_id|start_time|end_time| start_date|end_date | week_day|type_code
|26 |14:30:00 |16:30:00| 2007-12-03|2007-12-07| 550 | 201
|26 |14:30:00 |16:30:00| 2007-12-03|2007-12-07| 551 | 201
|26 |14:30:00 |16:30:00| 2007-12-03|2007-12-07| 552 | 201
|26 |14:30:00 |16:30:00| 2007-12-03|2007-12-07| 553 | 201
|26 |14:30:00 |16:30:00| 2007-12-03|2007-12-07| 554 | 201


CODE FOR ONE WEEK CYCLE

<?
   	$group_seg = array();
   	
         /*get group templates data to apply to schedule. This data contains 
            event/appointment types*/
   	$query = "SELECT distinct(s.seg_id), s.model_id, w.group_id, s.event_type_code,
   	                 s.time_from, s.time_to, w.weekday
   		  FROM cal_group_week w, cal_day_segment s
   		  WHERE s.model_id = w.model_id
   		  AND w.group_id = '$group_id'
   		  AND s.deleted = 'N'
   		  AND w.deleted = 'N'";
   	$result = mysqli_query ($mysqli, $query);
   	while($row = mysqli_fetch_array($result))
   		{
   		   $group_seg[] = $row;
  		}
   
   
         //loop through segment start and end time
         foreach($group_seg as $group_segment)
   	  {
   		  //database stored time from daily model segments
   		  $start_time = $group_segment['time_from'];
   		  $end_time = $group_segment['time_to'];
   		  $group_id = $group_segment['group_id'];
   		  $event_type_code = $group_segment['event_type_code'];
   		  $day = $group_segment['weekday'];
   		
   
   		
   	 /**-----------------------insert event type/appointment---------------------**/
   		    
   	 $cal_query = "INSERT INTO availablity(
    			 time_id, group_id, start_time, end_time, 
    			 start_date, end_date, week_day,  
                                                 type_code) 
    		      VALUES(  
                                                  null, '$group_id', '$start_time', '$end_time', '$start_date', 		                   '$end_date', '$day', '$event_type_code')";
   
   	 mysqli_query($mysqli, $cal_query)or die(mysqli_error($mysqli));		
   
     	 }//apply group
  
   
   ?>
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.