function GetBunkAvailability($eventid, $bookingtype, $bunks) { global $link, $today, $db_prefix; $sql = "select ifnull(sum(bkBunkAllocated), 0) as BunksAllocated from {$db_prefix}bookings where bkEventID = {$eventid} "; if ($bookingtype != "All") { $sql .= " and bkBookAs = '{$bookingtype}' "; } $result = ba_db_query($link, $sql); $BookingTypeAvailable = ba_db_fetch_row($result); $BookingTypeCount = $BookingTypeAvailable[0]; if ($BookingTypeCount >= $bunks) { return false; } return true; }
function ListNames($link, $sTable, $sColumn, $sDefault = '', $iDefaultNum = 0) { //Initialise $iOptionNum $iOptionNum = 1; //Query database to get group names $result = ba_db_query($link, "SELECT {$sColumn} FROM {$sTable} ORDER BY {$sColumn}"); while ($row = ba_db_fetch_row($result)) { //Note that " is used instead of ' in case there is a ' in any of the names echo '<option value = "' . htmlentities(stripslashes($row[0])) . '"'; if ($row[0] == $sDefault || $iOptionNum++ == $iDefaultNum) { echo ' selected'; } echo ">" . htmlentities(stripslashes($row[0])) . "</option>\n"; } }