whistlepig Posted April 1, 2007 Share Posted April 1, 2007 Could anyone offer a suggestion on how I could add multiple dates for the same activity that recurs many times in an events calendar? Now I am creating an entirely separate entry for each event; it all works fine, but it's mighty tedious! I'm posting my update page, which displays after a user selected a particular event and generated _GET['eventId']. <?php require_once('Connections/conn_dbname.php'); if (!isset($_SESSION)) { session_start(); } mysql_select_db($dbname, $conn_dbname); $query_rs_activity = "SELECT * FROM tbl_activity ORDER BY activityName"; $rs_activity = mysql_query($query_rs_activity); $row_rs_activity = mysql_fetch_assoc($rs_activity); $query_rs_location = "SELECT * FROM tbl_location ORDER BY locationName"; $rs_location = mysql_query($query_rs_location); $row_rs_location = mysql_fetch_assoc($rs_location); $query_rs_eventLocationDetail = "SELECT * FROM tbl_event INNER JOIN tbl_location ON tbl_location.locationId=tbl_event.eventLocation WHERE tbl_event.eventId=".$_GET['eventId']; $rs_eventLocationDetail = mysql_query($query_rs_eventLocationDetail); $row_rs_eventLocationDetail = mysql_fetch_assoc($rs_eventLocationDetail); $query_rs_eventDetail = "SELECT * FROM tbl_event INNER JOIN tbl_activity ON tbl_activity.activityId=tbl_event.eventActivity WHERE tbl_event.eventId=".$_GET['eventId']; $rs_eventDetail = mysql_query($query_rs_eventDetail); $row_rs_eventDetail = mysql_fetch_assoc($rs_eventDetail); ?> <!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>Untitled Document</title> </head> <body> <table width="100%" border="0" cellpadding="3" cellspacing="0"> <form id="frm_updateProfile" name="frm_updateProfile" method="post" action="admin_event_update_processor.php?eventId=<?php echo $_GET['eventId']; ?>"> <tr> <td colspan="9">Use the selection boxes below or add the information to update the event you selected: <p> </td> <tr> <td width="133">Activity</td> <td colspan="8" width="460"><select name="eventActivity" id="eventActivity"> <?php do { echo "<option value=\"".$row_rs_activity['activityId']\"". if ($row_rs_activity['activityId'] == $row_rs_eventDetail['eventActivity']){ echo "selected=\"selected\"". ">".$row_rs_activity['activityName'];."</option>"; } while ($row_rs_activity = mysql_fetch_assoc($rs_activity)); ?> </select> </td> </tr> <tr> <td width="133">Year <?php $year = getdate($row_rs_eventDetail['eventDate']); ?> </td> <td width="460"><select name="eventYear" id="eventYear"> <?php do { ?> <option value= "<?php echo $year[year]\""; if (!(strcmp($row_rs_eventDetail['eventDate'], $_GET['eventDate']))) {echo "selected=\"selected\"".">".$year[year]?> </option> <option value="2006">2006</option> <option value="2007">2007</option> <option value="2008">2008</option> <option value="2009">2009</option> <?php } while ($row_rs_eventDetail = mysql_fetch_assoc($rs_eventDetail)); $rows = mysql_num_rows($rs_eventDetail); if($rows > 0) { mysql_data_seek($rs_eventDetail, 0); $row_rs_eventDetail = mysql_fetch_assoc($rs_eventDetail); } ?> </select> </td> </tr> <tr> <td width="133">Month <?php $month = getdate($row_rs_eventDetail['eventDate']); ?> </td> <td width="460"><select name="eventMonth" id="eventMonth"> <?php do { echo "<option value=\"".$month[mon]\""; if (!(strcmp($row_rs_eventDetail['eventDate'], $_GET['eventDate']))) {echo "selected=\"selected\"";} ?> > <?php echo $month[mon]?> </option> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <?php } while ($row_rs_eventDetail = mysql_fetch_assoc($rs_eventDetail)); $rows = mysql_num_rows($rs_eventDetail); if($rows > 0) { mysql_data_seek($rs_eventDetail, 0); $row_rs_eventDetail = mysql_fetch_assoc($rs_eventDetail); } ?> </select> </td> </tr> <tr> <td width="133">Day <?php $day = getdate($row_rs_eventDetail['eventDate']); ?> </td> <td width="460"><select name="eventDay" id="eventDay"> <?php do { echo "<option value=\"". $day[mday]; if (!(strcmp($row_rs_eventDetail['eventDate'], $_GET['eventDate']))) {echo "selected=\"selected\"";} ">".$day[mday]?> </option> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> <?php } while ($row_rs_eventDetail = mysql_fetch_assoc($rs_eventDetail)); $rows = mysql_num_rows($rs_eventDetail); if($rows > 0) { mysql_data_seek($rs_eventDetail, 0); $row_rs_eventDetail = mysql_fetch_assoc($rs_eventDetail); } ?> </select> </td> </tr> <tr> <td colspan="2"><!--Check to make sure the timestamp is working echo $eventDate--> <?php { $eventDate = mktime(0,0,0,$eventMonth,$eventDay,$eventYear); $eventDate=$row_rs_eventDetail['eventDate']; } ?> </tr> <tr> <td width="133"> <td width="460"></td> </tr> <tr> <td width="133">Time of Event <td width="460"><input name="eventTime" type="text" id="eventTime" value="<?php echo $row_rs_eventDetail['eventTime']; ?>"/> </td> </tr> <tr> <td width="133">Location <td width="460"><select name="eventLocation" id="eventLocation"> <?php do { echo "<option value=\"".$row_rs_location['locationId']."\""; if ($row_rs_location['locationId'] == $row_rs_eventLocationDetail['eventLocation']) { echo " selected"; } echo ">".$row_rs_location['locationName']."</option>". } while ($row_rs_location = mysql_fetch_assoc($rs_location)); ?> </select> </td> </tr> <tr> <td colspan="2">Details (Contact information, directions to event location, etc.)</td> </tr> <tr> <td colspan="2"><textarea name="eventDetail" cols="45" rows="9" id="eventDetail"> <?php echo $row_rs_eventDetail['eventDetail']; ?></textarea> </td> </tr> <tr> <td colspan="3">Is this a recurring event? <input type="checkbox" name="eventRecurring" id="eventRecurring" value="<?php echo $row_rs_eventDetail['eventRecurring']; ?>"/> </td> <input name="admin" type="hidden" id="admin" value="<?php echo $_SESSION['MM_Username']; ?>" /> <input type="hidden" name="MM_insert" value="frm_updateProfile"> <tr> <td colspan="2"><input type="submit" name="Submit" value="Submit"> </td> </tr> </form> </table> </body> </html> <?php mysql_free_result($rs_eventLocationDetail); ?> As you can see from my code, I have a "recurring event?" checkbox that does nothing. I think I need to generate a completely different eventId from what is passed in, but I haven't a clue where to go from there. Does anyone have an idea how to do this a smart way and simplify the event-adding process? Thanks for any help you can offer! Link to comment https://forums.phpfreaks.com/topic/45192-multiple-dates-for-recurring-events/ Share on other sites More sharing options...
Barand Posted April 1, 2007 Share Posted April 1, 2007 A couple of approaches that can be taken for this one. 1 ) Have a form for entering recurring events specifying start date, end date, frequency, event details and loop from start date to end date, inserting events into your events table at the specified regular frequencies. 2 ) Have a separate table for recurring events, and when you display regular events, search the recurring events for any falling in the displayed timeframe. The main problem is frequency specification which can be simple (weekly on Monday, or the 3rd of each month) or slightly more complex such as 4th Thursday in November or 1st Sunday after the 4th full moon after Christmas (ie Easter) Link to comment https://forums.phpfreaks.com/topic/45192-multiple-dates-for-recurring-events/#findComment-219403 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.