I have a calendar program and in that program there is a window to popup to "Add an event". The code of the "add an event" is below after this message for you to see. In the code there is the ability to make the event repeating per day ie: every sunday, every friday, every 3rd thursday etc. But what about events that are 4 days in a row ie :starting on friday and ending on monday. The user would have to add 4 different events instead of one event that is 4 days long. I need to make that fix in this. can you help me please. I just took over this job so I am not really "into" this code, any advice is helpful
<?
$mylocale = $HTTP_COOKIE_VARS['mylocal
e'];
if ($mylocale == "") {
$mylocale = 1;
}
$types = array("944 Event",
"Art",
"Charity Event",
"Comedy",
"Family",
"Fashion",
"Festival",
"Magic",
"Movie/Film",
"Music",
"Networking",
"Party",
"Social Gathering",
"Sports",
"Theatre");
if(isset($entry["day"])) {
include_once($DOCUMENT_ROO
T . "/include/dbinfo.php");
# Do we really need to connect here?
# Yes, we do.
$con = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname, $con);
$title = "Calendar";
include($DOCUMENT_ROOT . "/main/inc/header.php");
# Include some nice utilities (form processing and such)
include("../include/utils.
inc.php");
# Check for an uploaded image file
if(is_uploaded_file($upIma
ge)) {
# There was an uploaded file
copy($upImage, "/home/httpd/vhosts/944.bi
z/httpdocs
/calendar/
images/" . $HTTP_POST_FILES["upImage"
]["name"])
;
$entry["image"] = $HTTP_POST_FILES["upImage"
]["name"];
}
if ($imageURL != "
http://" && $imageURL != "") {
$entry["image"] = $imageURL;
}
$entry['locale'] = $mylocale;
$entry[start_day] = "$entry[year]-$entry[month
]-$entry[d
ay]";
# Set up list of required fields
$required_fields = array(
'name' => 'Event Name',
'start_day' => 'Starting Day',
'time' => 'Time',
'type' => 'Event Type',
'venue' => 'Venue',
'yourname' => 'Your Name',
'youremail' => 'Your Email',
'yourphone' => 'Your Phone');
# Set up the rest of the fields
$all_fields = array_merge($required_fiel
ds, array(
'repeat_nth' => 'Repeat Nth',
'repeatday' => 'Repeat on Day...',
'image' => 'Uploaded Image',
'url' => 'Event Webpage',
'mapurl' => 'URL to map',
'status' => 'Status of event',
'cost' => 'Cost of event',
'repeat_event' => 'Event Repeats',
'description' => 'Description of event',
'locale' => 'Magazine Locale'));
if ($entry[url] == "
http://") {
$entry[url] = "";
}
# Check to make sure required fields aren't empty. If they are complain.
$empty_fields = get_empty_fields($entry, $required_fields);
if($empty_fields) {
foreach($empty_fields as $thefield) {
echo "Missing the requied field: '$thefield'<br />\n";
}
echo "click your browser's back button to return";
exit;
}
# Set up the query
$query = make_query($entry, $all_fields);
$res = mysql_query("INSERT INTO calendar SET $query", $con);
if ($res) {
echo "Entry added successfully.<br /><br />\n";
}
else {
echo "Entry was not added. Error: " . mysql_error() . "<br /><br />\n";
}
echo "<a href=\"showCalendarWeek.ph
p?day=" . $entry["day"] . "&month=" . $entry["month"] . "&year=" . $entry["year"] . "\">Return</a><br />\n";
$tRes = mysql_query("SELECT name FROM venues WHERE id='" . $entry[venue] . "'", $con);
if (!$tRes) {
print("Mysql Error: " . mysql_error() . "<br />\n");
}
else {
list($venue) = mysql_fetch_row($tRes);
}
$subject = "A Calendar Event For $entry[month]/$entry[day]/
$entry[yea
r] Was Submitted";
$from = "From: 944.biz <info@944.biz>";
$body = "An event was sent in for review for the event calendar. Click here to check it out:
http://www.944.biz/admin/calendar/index.php?year=$entry[year]&month=$entry[month]&day=$entry[day]\n\nMore info:\nEmail: $entry[youremail]\nEvent: $entry[name]\nVenue: $entry[venue]";
mail("signup@944.biz", $subject, $body, $from);
mail("billing@azsites.com"
, $subject, $body, $from);
mail("myles@azsites.com", $subject, $body, $from);
include($DOCUMENT_ROOT . "/main/inc/footer.php");
} else {
?>
<a id="add"></a>
<script language="JavaScript1.2" type="text/javascript">
<!--
function toggleRepeat() {
if(document.getElementById
('repeat')
.style.vis
ibility != 'hidden') {
document.getElementById('r
epeat').st
yle.visibi
lity = 'hidden';
document.getElementById('r
epeating')
.checked = 0;
} else {
document.getElementById('r
epeat').st
yle.visibi
lity = 'visible';
document.getElementById('r
epeating')
.checked = 1;
}
}
// -->
</script>
<center>
<table width="100%">
<tr>
<td align="center" valign="top">
<form action="add.php" method="post" enctype="multipart/form-da
ta">
<center>
<table class="form" id="formtable"
border="0" cellspacing="0">
<tr>
<td colspan="2" align="center">
<h2>Add an Event</h2>
</td>
</tr>
<tr>
<td>Event Name</td>
<td><input
type="text"
name="entry[name]"
size="30"
style="width:275"
value="<?=$entry["name"]?>
" />
</td>
</tr>
<tr>
<td>Event Date</td>
<td>
<select name="entry[month]">
<? $monthnum=1;
foreach(array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December') as $themonth) { ?>
<option value="<?=$monthnum?>" <?= ($monthnum == $month) ? 'SELECTED' : '' ?>><?=$themonth?></option>
<? $monthnum++; } ?>
</select>
<select name="entry[day]">
<? for($i = 1; $i < 32 ; $i++) { ?>
<option value="<?=$i?>" <?= ($i == $day) ? 'SELECTED' : '' ?>><?=$i?></option>
<? } ?>
</select>
<select name="entry[year]">
<? for($i = 2002; $i < 2006 ; $i++) { ?>
<option value="<?=$i?>" <?= ($i == $year) ? 'SELECTED' : '' ?>><?=$i?></option>
<? } ?>
</select>
</td>
</tr>
<tr>
<td>Event Time</td>
<!-- NOTE: Brock did NOT CREATE THE FOLLOWING! -->
<!-- In fact, anything ugly you see here, he did not create. -->
<!-- Just wanted to clear that up. -->
<!-- P.S. Myles didn't do it either... he thinks that the whole thing was Fred's fault. -->
<td>
<select name="entry[time]">
<?
if($entry["time"] == "") $entry["time"] = "19:00:00";
for($a = 7; $a <= 11; $a++) {
?>
<option value="<?=$a?>:00:00"<? if($entry["time"] == $a . ":00:00") { ?> SELECTED<? } ?>> <?=$a?>:00am </option>
<option value="<?=$a?>:30:00"<? if($entry["time"] == $a . ":30:00") { ?> SELECTED<? } ?>> <?=$a?>:30am </option>
<?
}
?>
<option value="12:00:00"<? if($entry["time"] == "12:00:00") { ?> SELECTED<? } ?>> Noon </option>
<option value="12:30:00"<? if($entry["time"] == "12:30:00") { ?> SELECTED<? } ?>> 12:30pm </option>
<?
for($a = 1; $a <= 11; $a++) {
?>
<option value="<?=$a+12?>:00:00"<?
if($entry["time"] == $a+12 . ":00:00") { ?> SELECTED<? } ?>> <?=$a?>:00pm </option>
<option value="<?=$a+12?>:30:00"<?
if($entry["time"] == $a+12 . ":30:00") { ?> SELECTED<? } ?>> <?=$a?>:30pm </option>
<?
}
?>
<option value="00:00:00"<? if($entry["time"] == "00:00:00") { ?> SELECTED<? } ?>> Midnight </option>
<option value="00:30:00"<? if($entry["time"] == "00:30:00") { ?> SELECTED<? } ?>> 12:30am </option>
<?
for($a = 1; $a <= 6; $a++) {
?>
<option value="<?=$a?>:00:00"<? if($entry["time"] == $a . ":00:00") { ?> SELECTED<? } ?>> <?=$a?>:00am </option>
<option value="<?=$a?>:30:00"<? if($entry["time"] == $a . ":30:00") { ?> SELECTED<? } ?>> <?=$a?>:30am </option>
<?
}
?>
</select>
<a href="javascript: toggleRepeat()">[Repeating
Event...]</a>
</td>
</tr>
<tr id="repeat" style="visibility: hidden">
<td>Repeats</td>
<td>
<input type="checkbox" name="entry[repeat_event]"
id="repeating" value="1" />
<select name="entry[repeat_nth]">
<option value="n1">1st</option>
<option value="n2">2nd</option>
<option value="n3">3rd</option>
<option value="last">Last</option>
<option value="every">Every</optio
n>
</select>
<select name="entry[repeatday]">
<option value="0">Sunday</option>
<option value="1">Monday</option>
<option value="2">Tuesday</option>
<option value="3">Wednesday</optio
n>
<option value="4">Thursday</option
>
<option value="5">Friday</option>
<option value="6">Saturday</option
>
</select>
of every month (Events will expire after 2 months)
</td>
</tr>
<tr>
<td>Event Type</td>
<td>
<select name="entry[type]" style="width:275">
<?
if($entry["type"] == "") $entry["type"] = "Music";
for($a = 0; $a < count($types); $a++) {
?>
<option value="<?=$types[$a]?>"<? if($entry["type"] == $types[$a]) { ?> SELECTED<? } ?>> <?=$types[$a]?> </option>
<?
}
?>
</select>
</td>
</tr>
<tr>
<td>Venue/Where</td>
<td>
<select name="entry[venue]" style='width:275'>
<?
$res = mysql_query("
SELECT id, name
FROM venues
WHERE active='1' AND (locale=0 OR locale=$mylocale) ORDER BY name");
if(mysql_num_rows($res) > 0) {
while($venue = mysql_fetch_array($res)) { ?>
<option value="<?=$venue["id"]?>"
<?=
($entry["venue"] == $venue["id"])
? 'SELECTED' : ''
?>
>
<?=$venue["name"]?>
</option>
<?
}
}
?>
<option value="Other"<? if ($entry['venue'] == "") print(" selected"); ?>>
Other (put in description)
</option>
</select>
</td>
</tr>
<tr>
<td>Your Name</td>
<td><input
type="text"
name="entry[yourname]"
size="30"
style="width:275"
value="<?=$entry[yourname]
?>" />
</td>
</tr>
<tr>
<td>Your Email</td>
<td><input
type="text"
name="entry[youremail]"
size="30"
style="width:275"
value="<?=$entry[youremail
]?>" />
</td>
</tr>
<tr>
<td>Your Phone#</td>
<td><input
type="text"
name="entry[yourphone]"
size="30"
style="width:275"
value="<?=$entry[yourphone
]?>" />
</td>
</tr>
<tr><td colspan="2"> </td></t
r>
<tr>
<td colspan="2" align="center">
<input
type="submit"
name="suggest"
value="Submit Event for Approval" />
</td>
</tr>
</table>
</td>
<td align="center" valign="top">
<table id='advanced' class=form>
<tr>
<td colspan="2" align="center">
<h2>Advanced / Description</h2>
</td>
</tr>
<tr>
<td>Webpage (http...)</td>
<?
if ($entry[url] == "") {
$entry[url] = "
http://";
}
?>
<td><input
type="text"
name="entry[url]"
size=30
style="width:275"
value="<?=$entry[url]?>" />
</td>
</tr>
<tr>
<td valign="top">Description</
td>
<td><textarea cols="36" rows="10" style="width:275" name="entry[description]">
</textarea
></td>
</tr>
<tr>
<td>Image (4"x4" max)</td>
<td><input
type="file"
name="upImage" /> <b>OR</b>
</td>
</tr>
<? if($entry["image"] != "") { ?>
<tr>
<td>Current image</td>
<td><a href="/calendar/images/<?=
$entry["im
age"]?>"
target="_blank"><?=$entry[
"image"]?>
</a>
</td>
</tr>
<? } ?>
<?
if ($imageURL == "") {
$imageURL = "
http://";
}
?>
<td> </td>
<td><input
type="text"
name="imageURL"
size="20"
style="width:200"
value="<?=$imageURL?>" /> (Existing image)
</td>
</tr>
<tr>
<td>Link to Map (http...)</td>
<td><input
type="text"
name="entry[mapurl]"
size=30
style="width:275"
value="<?=$entry[mapurl]?>
" />
</td>
</tr>
<tr>
<td>Cost/Status</td>
<?
if ($entry["status"] == "") {
$entry["status"] = "TBA";
}
?>
<td>
<select name="entry[status]">
<option<? if($entry["status"] == "BUY") { ?> SELECTED<? } ?>>BUY</option>
<option<? if($entry["status"] == "FREE") { ?> SELECTED<? } ?>>FREE</option>
<option<? if($entry["status"] == "CANCELLED") { ?> SELECTED<? } ?>>CANCELLED</option>
<option<? if($entry["status"] == "DONATIONS") { ?> SELECTED<? } ?>>DONATIONS</option>
<option<? if($entry["status"] == "DOOR COVER") { ?> SELECTED<? } ?>>DOOR COVER</option>
<option<? if($entry["status"] == "TBA") { ?> SELECTED<? } ?>>TBA</option>
</select>
Amount (if applicable)
<input type="text" name="entry[cost]" size="5" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<?
}
?>