2017 Keelboat Racing

Registrations Received

query($query);

//Set up our query to query rows from the WordPress Gravity Forms table.

$query = “SELECT d.field_number, d.value FROM $usertable1 l INNER JOIN $usertable2 d ON l.id = d.lead_id WHERE l.form_id = $form_num AND l.status = ‘active’ ORDER BY lead_id, field_number”;

//Run the Query

$result = $wpdb->get_results($query);

if($result)
{
foreach($result as $key => $row)
{
$field_number = $row->field_number;
switch($field_number)
{
case 1.3:
$fname = $row->value;
break;
case 1.6:
$lname = $row->value;
break;
case 5:
$boattype = $row->value;
break;
case 6:
$boatlength = $row->value;
break;
case 8:
$yachtclub = $row->value;
break;
case 44:
$boatname = $row->value;
break;
case 45:
$sailnumber = $row->value;
break;
case 46:
$phrf = $row->value;
break;
case 49:
$fleettype = $row->value;
break;
case 53:
$insurance = $row->value;
break;
case 54:
$validphrf = $row->value;

$wpdb->query( $wpdb->prepare(
“INSERT INTO temp_table_1 (lname, fname, fleettype, boatname, boattype, boatlength, sailnumber, phrf, yachtclub, insurance, validphrf) VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )”,
array(
$lname,
$fname,
$fleettype,
$boatname,
$boattype,
$boatlength,
$sailnumber,
$phrf,
$yachtclub,
$insurance,
$validphrf
)
));
$lname = “”;
$fname = “”;
$fleettype = “”;
$boatname = “”;
$boattype = “”;
$boatlength = “”;
$sailnumber = “”;
$phrf = “”;
$yachtclub = “”;
$insurance = “”;
$validphrf = “”;
break;
default:
break;
}
}
}
//Set up our query to query rows from the WordPress temp_table_1 table.

$query = “SELECT
lname,
fname,
fleettype,
boatname,
boattype,
boatlength,
sailnumber,
phrf,
yachtclub,
insurance,
validphrf
FROM temp_table_1
ORDER BY fleettype, boattype, lname, fname”;

//Run the Query

$result = $wpdb->get_results($query);

if($result)
{
foreach($result as $key => $row)
{
$lname = $row->lname;
$fname = $row->fname;
$fleettype = $row->fleettype;
$boatname = $row->boatname;
$boattype = $row->boattype;
$boatlength = $row->boatlength;
$sailnumber = $row->sailnumber;
$phrf = $row->phrf;
$yachtclub = $row->yachtclub;
$insurance = $row->insurance;
$validphrf = $row->validphrf;
echo “

“;
}
}
$query = “DROP TABLE temp_table_1”;
$wpdb->query($query);
?>

Name Fleet Boat Name Boat Type Sail # PHRF # Yacht Club Rcvd. Insur. Rcvd. PHRF
” . $lname . “, ” . $fname . “ ” . $fleettype . “ ” . $boatname . “ ” . $boattype . “ ” . $sailnumber . “ ” . $phrf . “ ” . $yachtclub . “ ” . $insurance . “ ” . $validphrf . “