$locationset = $db_object->get_rsltset($query);
        preg_match("/<{location_loopstart}>(.*?)<{location_loopend}>/s", $xTemplate, $match);
        $replace = $match[1];
        for ($i = 0; $i < count($locationset); $i++) {
            $sub_denotes = $locationset[$i]["denotes"] + 1;
            $name = $locationset[$i]["loc_name"];
            $id = $locationset[$i]["loc_id"];
            $re .= preg_replace("/<{(.*?)}>/e", "\$\$1", $replace);
        }
        $xTemplate = preg_replace("/<{location_loopstart}>(.*?)<{location_loopend}>/s", $re, $xTemplate);
        echo $xTemplate;
    }
    function addnew_location($common, $db_object, $form_array, $denotes)
    {
        while (list($kk, $vv) = each($form_array)) {
            ${$kk} = $vv;
        }
        $location = $common->prefix_table("location");
        $query = "insert into {$location} set loc_name='{$fLocation_name}',denotes='{$denotes}'";
        $sub_id = $db_object->insert_data_id($query);
        $location_relate = $common->prefix_table("location_relate");
        $query = "insert into {$location_relate} set loc_id='{$id}',sub_id='{$sub_id}'";
        $db_object->insert($query);
    }
}
$locobj = new Locations();
if ($fAdd) {
    $locobj->addnew_location($common, $db_object, $_POST, $denotes);
}
$locobj->location_display($common, $db_object, $denotes, $_POST, $id, $gbl_loc);
include "footer.php";