+ Post New Thread
Results 1 to 3 of 3
Coding Thread, Help adding a custom field in to Meeting room booking system (MRBS) in Coding and Web Development; Hi, we are looking at using MRBS over our Excel booking system next year and ive been asked if we ...
  1. #1

    Join Date
    Dec 2007
    Location
    Nottinghamshire
    Posts
    187
    Thank Post
    59
    Thanked 21 Times in 19 Posts
    Rep Power
    17

    Help adding a custom field in to Meeting room booking system (MRBS)

    Hi, we are looking at using MRBS over our Excel booking system next year and ive been asked if we can add a few bits in to it, however my PHP knowledge isnít very good.

    We are trying to add a dropdown box that contains the subjects for our site and enter this in to a mysql database (MRBS_entry in a field called Subject)

    I have been able to get all the subjects out of a MySQL database without too much difficulty and put them in to a drop down box using the following code

    Code:
        <p>
          <select id="Subject" name="Subject[]">
            <?php 
            // select the Subject 
    		$sql = "select ID, Subject from $tbl_subjects order by Subject";
            $res = sql_query($sql);
            if ($res)
            {
              for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
              {
                $selected = "";
                if ($row['id'] == $Subject)
                {
                  $selected = "selected=\"selected\"";
                }
                echo "              <option $selected value=\"" . $row['id'] . "\">" . htmlspecialchars($row['Subject']) . "</option>\n";
                // store room names for emails
                $room_names[$i] = $row['Subject'];
              }
            }
            ?>
                </select>
          <span><?php echo "Select your Subject" ?></span></p>
    Iím guessing that my code is very messy, sorry for that, but it works and puts the subjects in a dropdown box.


    What I canít get right is the code to get the information in to the MySQL database. My understanding is that the code comes from MRBS_sql.inc and I think that the code that I need to change is

    Code:
    /** mrbsCreateSingleEntry()
     * 
     * Create a single (non-repeating) entry in the database
     * 
     * $starttime   - Start time of entry
     * $endtime     - End time of entry
     * $entry_type  - Entry type
     * $repeat_id   - Repeat ID
     * $room_id     - Room ID
     * $owner       - Owner
     * $name        - Name
     * $type        - Type (Internal/External)
     * $description - Description
     * $private     - Private Booking (TRUE/FALSE)
     * $status      - Status code of the entry
     * $Subject	- Subject for the Booking
     * 
     * Returns:
     *   0        - An error occured while inserting the entry
     *   non-zero - The entry's ID
     */
    function mrbsCreateSingleEntry($starttime, $endtime, $entry_type, $repeat_id,
                                   $room_id, $owner, $name, $type, $description,
                                   $private, $status, $Subject)
    {
      global $tbl_entry;
     
      $private = $private ? 1 : 0;
      $name        = addslashes($name);
      $description = addslashes($description);
      $owner       = addslashes($owner);
      $type        = addslashes($type);
       
      // make sure that any entry is of a positive duration
      // this is to trap potential negative duration created when DST comes
      // into effect
      if ($endtime > $starttime)
      {
        $sql = "INSERT INTO $tbl_entry (start_time, end_time, entry_type, repeat_id, room_id, create_by, name, type, description, private, status, Subject) VALUES ($starttime, 
    
    $endtime, $entry_type, $repeat_id, $room_id, '$owner', '$name', '$type', '$description', $private, $status, '$Subject')";
    Code:
          $ent_id = mrbsCreateSingleEntry($reps[$i],
                                          $reps[$i] + $diff,
                                          1,
                                          $id,
                                          $room_id,
                                          $owner,
                                          $name,
                                          $type,
                                          $description,
                                          $private,
                                          $status,
    		         $Subject);
        }
      }
      $result['id'] = $id;
      $result['series'] = TRUE;
      return $result;
    }
    When submitting this to the database it is entering the information for everything else but the subject so I think that Iím not getting the information out of the form correctly or I have not edited the correct SQL insert.

    With any luck someone else will have done something similar before and can point me in the right direction

    If needed i can post the PHP and INC files.

    Thanks in advance

  2. #2

    CESIL's Avatar
    Join Date
    Nov 2006
    Location
    Hampshire
    Posts
    1,403
    Thank Post
    109
    Thanked 267 Times in 198 Posts
    Rep Power
    168
    Have you checked whether the subject is being sent by the form? If you have added a field to an existing form, is it inside the <form></form> tags?
    I usually use the following to test these problems...
    Code:
    echo "<pre>";
    print_r($_POST);
    echo "</pre>";
    save this as a test page and redirect your form to it.
    Then you will get the form data printed as an array.
    If you are using GET instead of POST then change $_POST to $_GET

  3. Thanks to CESIL from:

    notalot (9th June 2010)

  4. #3

    Join Date
    Dec 2007
    Location
    Nottinghamshire
    Posts
    187
    Thank Post
    59
    Thanked 21 Times in 19 Posts
    Rep Power
    17
    Thanks CESIL that's what I needed, from that I was able to pin down and fix the code.

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 22
    Last Post: 17th August 2010, 05:38 PM
  2. Replies: 0
    Last Post: 29th March 2010, 09:23 AM
  3. MRBS room booking assigning admins
    By lill in forum How do you do....it?
    Replies: 0
    Last Post: 9th November 2009, 04:19 PM
  4. Meeting Room Booking System - MRBS
    By pmassingham in forum How do you do....it?
    Replies: 4
    Last Post: 12th February 2009, 11:03 AM
  5. Meeting Room Booking System - examples config inside!
    By db260179 in forum Network and Classroom Management
    Replies: 7
    Last Post: 25th July 2007, 07:07 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •