if ($filter == "scores") {
     $table_head1 .= "<th class='dataList bdr1B' width='1%' nowrap='nowrap'>Score</th>";
 }
 $table_head1 .= "</tr>";
 // Build table body
 include DB . 'scores.db.php';
 do {
     $style = $row_scores['brewCategory'] . $row_scores['brewSubCategory'];
     $table_body1 .= "<tr>";
     if ($action == "print") {
         $table_body1 .= "<td class='data' style='bdr1B'>";
         $table_body1 .= display_place($row_scores['scorePlace'], 1);
         $table_body1 .= "</td>";
     } else {
         $table_body1 .= "<td class='data'>";
         $table_body1 .= display_place($row_scores['scorePlace'], 2);
         $table_body1 .= "</td>";
     }
     if ($action == "print") {
         $table_body1 .= "<td class='data' style='bdr1B'>";
     } else {
         $table_body1 .= "<td class='data'>";
     }
     $table_body1 .= $row_scores['brewerFirstName'] . " " . $row_scores['brewerLastName'];
     if ($row_scores['brewCoBrewer'] != "") {
         $table_body1 .= "<br>Co-Brewer: " . $row_scores['brewCoBrewer'];
     }
     $table_body1 .= "</td>";
     if ($action == "print") {
         $table_body1 .= "<td class='data' style='bdr1B'>";
     } else {
function winner_check($id, $judging_scores_db_table, $judging_tables_db_table, $brewing_db_table, $method)
{
    require CONFIG . 'config.php';
    mysql_select_db($database, $brewing);
    if ($method == 6) {
        // reserved for NHC admin advance
        $r = "Administrative Advance";
    }
    if ($method == "") {
        $r = "";
    }
    if ($method < 6) {
        $query_scores = sprintf("SELECT eid,scorePlace,scoreTable FROM %s WHERE eid='%s'", $judging_scores_db_table, $id);
        $scores = mysql_query($query_scores, $brewing) or die(mysql_error());
        $row_scores = mysql_fetch_assoc($scores);
        if ($row_scores['scorePlace'] >= "1") {
            if ($method == "0") {
                // Display by Table
                $query_table = sprintf("SELECT tableName FROM {$judging_tables_db_table} WHERE id='%s'", $row_scores['scoreTable']);
                $table = mysql_query($query_table, $brewing) or die(mysql_error());
                $row_table = mysql_fetch_assoc($table);
                $r = display_place($row_scores['scorePlace'], 1) . ": " . $row_table['tableName'];
            }
            if ($method == "1") {
                // Display by Category
                $query_entry = sprintf("SELECT brewCategorySort FROM {$brewing_db_table} WHERE id='%s'", $row_scores['eid']);
                $entry = mysql_query($query_entry, $brewing) or die(mysql_error());
                $row_entry = mysql_fetch_assoc($entry);
                $r = display_place($row_scores['scorePlace'], 1) . ": " . style_convert($row_entry['brewCategorySort'], 1);
            }
            if ($method == "2") {
                // Display by Category
                $query_entry = sprintf("SELECT brewCategorySort,brewCategory,brewSubCategory FROM {$brewing_db_table} WHERE id='%s'", $row_scores['eid']);
                $entry = mysql_query($query_entry, $brewing) or die(mysql_error());
                $row_entry = mysql_fetch_assoc($entry);
                $query_style = sprintf("SELECT brewStyle FROM %s WHERE (brewStyleVersion='%s' OR brewStyleOwn='custom') AND brewStyleGroup='%s' AND brewStyleNum='%s'", $prefix . "styles", $_SESSION['prefsStyleSet'], $row_entry['brewCategorySort'], $row_entry['brewSubCategory']);
                $style = mysql_query($query_style, $brewing) or die(mysql_error());
                $row_style = mysql_fetch_assoc($style);
                $r = display_place($row_scores['scorePlace'], 1) . ": " . $row_style['brewStyle'] . " (" . $row_entry['brewCategory'] . $row_entry['brewSubCategory'] . ")";
            }
        } else {
            $r = "";
        }
    }
    //$r = "<td class=\"dataList\">".$query_scores."<br>".$query_table."</td>";
    return $r;
}
 $html .= '<tr>';
 if ($row_sbi['sbi_display_places'] == "1") {
     $html .= '<td width="35" align="center"  bgcolor="#cccccc" nowrap="nowrap"><strong>Place</strong></td>';
 }
 $html .= '<td width="150" align="center" bgcolor="#cccccc"><strong>Brewer(s)</strong></td>';
 $html .= '<td width="200" align="center" bgcolor="#cccccc"><strong>Entry Name</strong></td>';
 $html .= '<td width="200" align="center" bgcolor="#cccccc"><strong>Style</strong></td>';
 $html .= '<td width="175" align="center" bgcolor="#cccccc"><strong>Club</strong></td>';
 $html .= '</tr>';
 do {
     $brewer_info = explode("^", brewer_info($row_sbd['bid']));
     $entry_info = explode("^", entry_info($row_sbd['eid']));
     $style = $entry_info['5'] . $entry_info['2'];
     $html .= '<tr>';
     if ($row_sbi['sbi_display_places'] == "1") {
         $html .= '<td width="35" nowrap="nowrap">' . display_place($row_sbd['sbd_place'], 4) . '</td>';
     }
     $html .= '<td width="150">' . $brewer_info['0'] . " " . $brewer_info['1'];
     if ($row_entries['brewCoBrewer'] != "") {
         $html .= "<br />Co-Brewer: " . $entry_info['4'];
     }
     $html .= '</td>';
     $html .= '<td width="200">' . strtr($entry_info['0'], $html_remove) . '</td>';
     $html .= '<td width="200">' . $style . ": " . $entry_info['3'] . '</td>';
     $html .= '<td width="175">';
     if ($brewer_info['7'] != "") {
         $html .= strtr($brewer_info['8'], $html_remove);
     } else {
         $html .= "&nbsp;";
     }
     $html .= '</td>';
     $checked = "CHECKED";
 } elseif (!empty($assignment_checked) && $filter == "staff" && strpos($brewer_assignment, 'Staff') !== false) {
     $checked = "CHECKED";
 } elseif (!empty($assignment_checked) && $filter == "bos" && strpos($brewer_assignment, 'BOS') !== false) {
     $checked = "CHECKED";
 } else {
     $checked = "";
 }
 if ($filter == "bos") {
     $bos_judge_eligible = bos_judge_eligible($row_brewer['uid']);
     if (!empty($bos_judge_eligible)) {
         $places_earned = explode("|", $bos_judge_eligible);
         $judge_places = "";
         foreach ($places_earned as $places) {
             $places_earned = explode("-", $places);
             $judge_places .= display_place($places_earned[0], 1) . ": Table " . $places_earned[1] . ", ";
         }
         $judge_places = rtrim($judge_places, ", ");
     }
 }
 if ($filter == "judges" || $filter == "stewards") {
     if ($filter == "judges") {
         $exploder = $row_brewer['brewerJudgeLocation'];
     }
     if ($filter == "stewards") {
         $exploder = $row_brewer['brewerStewardLocation'];
     }
     $a = explode(",", $exploder);
     $output = "";
     if ($exploder != "") {
         sort($a);
 $table_head2 .= "<th width='25%'>Style</th>";
 $table_head2 .= "<th>Club</th>";
 // Build table body
 do {
     $brewer_info = explode("^", brewer_info($row_sbd['bid']));
     $entry_info = explode("^", entry_info($row_sbd['eid']));
     $style = $entry_info['5'] . $entry_info['2'];
     $table_body2 .= "<tr>";
     if ($row_sbi['sbi_display_places'] == "1") {
         if ($action == "print") {
             $table_body2 .= "<td>";
             $table_body2 .= display_place($row_sbd['sbd_place'], 0);
             $table_body2 .= "</td>";
         } else {
             $table_body2 .= "<td>";
             $table_body2 .= display_place($row_sbd['sbd_place'], 3);
             $table_body2 .= "</td>";
         }
     }
     if ($action == "print") {
         $table_body2 .= "<td>";
     } else {
         $table_body2 .= "<td>";
     }
     $table_body2 .= $brewer_info['0'] . " " . $brewer_info['1'];
     if (!empty($entry_info['4'])) {
         $table_body2 .= "<br />Co-Brewer: " . $entry_info['4'];
     }
     $table_body2 .= "</td>";
     if ($action == "print") {
         $table_body2 .= "<td>";
        $row_score_count = mysql_fetch_assoc($score_count);
        if ($row_entry_count['count'] > 0 && $row_score_count['count'] > 0) {
            $query_scores = sprintf("SELECT a.scorePlace, b.brewName, b.brewCategory, b.brewSubCategory, b.brewStyle, c.brewerLastName, c.brewerFirstName, c.brewerClubs FROM %s a, %s b, %s c WHERE b.brewCategorySort='%s' AND b.brewSubCategory='%s' AND a.eid = b.id  AND c.uid = b.brewBrewerID  AND (a.scorePlace IS NOT NULL OR a.scorePlace='') ORDER BY a.scorePlace", $judging_scores_db_table, $brewing_db_table, $brewer_db_table, $style[0], $style[1]);
            $scores = mysql_query($query_scores, $brewing) or die(mysql_error());
            $row_scores = mysql_fetch_assoc($scores);
            $totalRows_scores = mysql_num_rows($scores);
            do {
                $text = sprintf("\n%s%s\n%s\n%s", display_place($row_scores['scorePlace'], 1) . " - ", $row_scores['brewCategory'] . $row_scores['brewSubCategory'] . ": " . $row_scores['brewStyle'], strtr($row_scores['brewerFirstName'], $html_remove) . " " . strtr($row_scores['brewerLastName'], $html_remove), strtr($row_scores['brewName'], $html_remove));
                $text = iconv('UTF-8', 'windows-1252', $text);
                $pdf->Add_Label($text);
            } while ($row_scores = mysql_fetch_assoc($scores));
        }
    }
} else {
    // Output by Table.
    do {
        $query_scores = sprintf("SELECT * FROM %s WHERE scoreTable='%s'", $judging_scores_db_table, $row_tables['id']);
        $query_scores .= " AND (scorePlace='1' OR scorePlace='2' OR scorePlace='3' OR scorePlace='4' OR scorePlace='5') ORDER BY scorePlace ASC";
        $scores = mysql_query($query_scores, $brewing) or die(mysql_error());
        $row_scores = mysql_fetch_assoc($scores);
        $totalRows_scores = mysql_num_rows($scores);
        do {
            $query_entries = sprintf("SELECT id,brewBrewerFirstName,brewBrewerLastName,brewName,brewStyle,brewCategory,brewSubCategory FROM {$brewing_db_table} WHERE id='%s'", $row_scores['eid']);
            $entries = mysql_query($query_entries, $brewing) or die(mysql_error());
            $row_entries = mysql_fetch_assoc($entries);
            $text = sprintf("\n%s%s\n%s\n%s", display_place($row_scores['scorePlace'], 1) . " - ", $row_tables['tableName'], strtr($row_entries['brewBrewerFirstName'], $html_remove) . " " . strtr($row_entries['brewBrewerLastName'], $html_remove), strtr($row_entries['brewName'], $html_remove));
            $text = iconv('UTF-8', 'windows-1252', $text);
            $pdf->Add_Label($text);
        } while ($row_scores = mysql_fetch_assoc($scores));
    } while ($row_tables = mysql_fetch_assoc($tables));
}