2017 Dinghy 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 8:
$yachtclub = $row->value;
break;
case 45:
$sailnumber = $row->value;
$wpdb->query( $wpdb->prepare(
“INSERT INTO temp_table_1 (lname, fname, boattype, sailnumber, yachtclub) VALUES ( %s, %s, %s, %s, %s )”,
array(
$lname,
$fname,
$boattype,
$sailnumber,
$yachtclub
)
));
$lname = “”;
$fname = “”;
$boattype = “”;
$sailnumber = “”;
$yachtclub = “”;
break;
default:
break;
}
}
}
//Set up our query to query rows from the WordPress temp_table_1 table.

$query = “SELECT
lname,
fname,
boattype,
sailnumber,
yachtclub
FROM temp_table_1
ORDER BY boattype, lname, fname”;

//Run the Query

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

if($result)
{
foreach($result as $key => $row)
{
$lname = $row->lname;
$fname = $row->fname;
$boattype = $row->boattype;
$sailnumber = $row->sailnumber;
$yachtclub = $row->yachtclub;
echo “

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

Name Boat Type Sail Number Yacht Club
” . $lname . “, ” . $fname . “ ” . $boattype . “ ” . $sailnumber . “ ” . $yachtclub . “