[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

3.6

PHP programming question..

Asked by MasterMitch in PHP and Databases

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['mylocale'];
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_ROOT . "/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($upImage)) {
    # There was an uploaded file
    copy($upImage, "/home/httpd/vhosts/944.biz/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[day]";

  # 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_fields, 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.php?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[year] 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.visibility != 'hidden') {
            document.getElementById('repeat').style.visibility = 'hidden';
            document.getElementById('repeating').checked = 0;
          } else {
            document.getElementById('repeat').style.visibility = 'visible';
            document.getElementById('repeating').checked = 1;
          }
        }
      // -->
    </script>
          <center>
          <table width="100%">
          <tr>
          <td align="center" valign="top">
          <form action="add.php" method="post" enctype="multipart/form-data">
            <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>
                  &nbsp;&nbsp;
                  <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</option>
                  </select>
                  <select name="entry[repeatday]">
                    <option value="0">Sunday</option>
                    <option value="1">Monday</option>
                    <option value="2">Tuesday</option>
                    <option value="3">Wednesday</option>
                    <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">&nbsp;</td></tr>
              <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["image"]?>"
                    target="_blank"><?=$entry["image"]?></a>
                  </td>
                </tr>
              <? } ?>
              <?
                    if ($imageURL == "") {
                          $imageURL = "http://";
                    }
              ?>
                <td>&nbsp;</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>
<?
  }
?>
 
[+][-]06/07/03 06:45 PM, ID: 8674767Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: PHP and Databases
Sign Up Now!
Solution Provided By: girish_nair
Participating Experts: 2
Solution Grade: B
 
[+][-]06/07/03 07:28 PM, ID: 8674886Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/08/03 02:22 AM, ID: 8675811Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/10/03 12:48 AM, ID: 8688613Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/10/03 01:30 AM, ID: 8688778Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/10/03 03:03 AM, ID: 8689245Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/10/03 08:09 AM, ID: 8691549Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/10/03 05:34 PM, ID: 8695511Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/10/03 07:07 PM, ID: 8695892Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06/10/03 07:16 PM, ID: 8695931Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/10/03 08:01 PM, ID: 8696113Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/10/03 09:00 PM, ID: 8696371Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/10/03 11:12 PM, ID: 8696900Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/10/03 11:17 PM, ID: 8696915Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/11/03 08:15 AM, ID: 8700531Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/11/03 01:15 PM, ID: 8702936Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/11/03 01:56 PM, ID: 8703256Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/11/03 02:09 PM, ID: 8703344Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/11/03 07:02 PM, ID: 8704862Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/11/03 07:38 PM, ID: 8704986Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/11/03 08:35 PM, ID: 8705233Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/11/03 08:49 PM, ID: 8705298Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/11/03 11:05 PM, ID: 8705941Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/12/03 03:26 AM, ID: 8707327Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/12/03 03:57 AM, ID: 8707487Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/13/03 01:04 PM, ID: 8720430Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/13/03 01:08 PM, ID: 8720462Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/16/03 08:19 PM, ID: 8737289Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/17/03 05:56 AM, ID: 8739959Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/17/03 10:13 AM, ID: 8742404Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81