while ($uid = $rsUID->FetchRow()) {
    $uids[$uid['GFID']] = $uid['UID'];
}
// retrieve all details for registration
$rsRego = $db->Execute("SELECT RegoID, DATE_FORMAT(RegoTime, '%a, %d %b %Y, %T') AS RegoTime, PriceTotal, PricePaid, ((PriceTotal - PricePaid) = 0) AS PaidFull, " . "`" . implode("`, `", $uids) . "` " . "FROM " . TBL_DETAILS . " " . "WHERE RegoID = '" . $_GET['view'] . "'");
$rego = $rsRego->FetchRow();
// select all visibility conditions (to calculate which fields don't need to be shown)
$rsVisCond = $db->Execute("SELECT GID, 0 AS FID, CONCAT('g', GID, 'f0') AS GFID, VisCond " . "FROM " . TBL_GROUPS . " " . "WHERE VisCond <> '' " . "UNION " . "SELECT GID, FID, CONCAT('g', GID, 'f', FID) AS GFID, VisCond " . "FROM " . TBL_FIELDS . " " . "WHERE VisCond <> ''");
// some initial states may vary from database based on submitted data
$newInitState = array();
while ($visCond = $rsVisCond->FetchRow()) {
    if (!($vc = vcParse($visCond['VisCond']))) {
        continue;
    }
    // go to next iteration if invalid visibility condition
    $newInitState[$visCond['GFID']] = (vcCompareValue($rego[$uids[$vc['gfid']]], $vc['value']) xor $vc['negate']) ? 2 : 0;
}
?>
<table width="100%"  border="0" align="center" cellspacing="20" id="outerform">
	<tr>
		<td>
			<table border="0" align="center" cellspacing="10" id="regoform">
				<tr>
					<td>
						<table width="100%">
							<tr>
								<td width="150"><strong>Reference Number:</strong></td>
								<td><?php 
echo $rego['RegoID'];
?>
</td>
 // some initial states may vary from database based on submitted data
 $errorInitState = array();
 while ($visCond = $rsVisCond->FetchRow()) {
     if (!($vc = vcParse($visCond['VisCond']))) {
         continue;
     }
     // go to next iteration if invalid visibility condition
     if ($visCond['FID'] == 0) {
         // group
         if (!($compare = (vcCompareValue(isset($_POST[$vc['gfid']]) ? $_POST[$vc['gfid']] : 0, $vc['value']) xor $vc['negate']))) {
             $ignoreGroups[] = $visCond['GID'];
         }
         $errorInitState[$visCond['GFID']] = $compare ? 2 : ($vc['action'] == "visible" ? 0 : 1);
     } else {
         // field
         if (!($compare = (vcCompareValue(isset($_POST[$vc['gfid']]) ? $_POST[$vc['gfid']] : 0, $vc['value']) xor $vc['negate']))) {
             $ignoreFields[] = $visCond['GFID'];
         }
         $errorInitState[$visCond['GFID']] = $compare ? 2 : ($vc['action'] == "visible" ? 0 : 1);
     }
 }
 while (!$finished && ($validate = $rsValidate->FetchRow())) {
     // if group or field is in the ignored list, skip to next iteration
     if (in_array($validate['GID'], $ignoreGroups) || in_array($validate['GFID'], $ignoreFields)) {
         continue;
     }
     switch ($validate['Type']) {
         case 2:
             // text field
         // text field
         case 3: