This topic is locked

lookup / date / time restriction

7/6/2006 7:11:24 PM
PHPRunner General questions
M
mfred author

I am using PHPRunner to create a room booking application. I got everything figured out except one thing. My client wants to prevent dual booking. The booking method that I am using is for the user to select the room from a lookup, select the begin date / time and the end date / time. PHPRunner does all this well but I need to see if I can restrict the users from selected an already booked room. My assumption is to somehow code the program to prevent a user from selecting the same room at the same time as someone else. But I am unsure how to do this. Any help is appreciated.

J
Jane 7/7/2006

Hi,
you can do it using event.

Proceed to the Events tab, select Before record added event and choose check if specific record exist action.

Here is a sample code:

function BeforeEdit(&$values, $where)

{

// Parameters:

// $values - Array object.

// Each field on the Edit form represented as 'Field name'-'Field value' pair

// $where - string with WHERE clause pointing to record to be edited
//** Check if specific record exists ****

global $conn;

$strSQLExists = "select * from AnyTable where AnyColumn='AnyValue'";

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);

if($data)

{

// if record exists do something

}

else

{

// if dont exist do something else

}

return true;
// return true if you like to proceed with editing this record

// return false in other case

}