Jump to content

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


Recommended Posts

Posted

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

 

    

     
               // 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 "              " . htmlspecialchars($row['Subject']) . "\n";
           // store room names for emails
           $room_names[$i] = $row['Subject'];
         }
       }
       ?>
           
      

 

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

 

/** 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')";

      $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

Posted

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

tags?

I usually use the following to test these problems...

echo "";
print_r($_POST);
echo "";

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

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...