2015 Mothers Day Brunch

Reservations 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 d.lead_id, d.field_number”;
//echo $query;
//Run the Query

$result = $wpdb->get_results($query);
if($result)
{
foreach($result as $key => $row)
{
$field_number = $row->field_number;
//echo $field_number . “, “;
switch($field_number)
{
case 2.3:
$fname = $row->value;
break;
case 2.6:
$lname = $row->value;
break;
case 3:
$phone = $row->value;
break;
case 4.3:
$adults = $row->value;
break;
case 9:
$paymenttype = $row->value;
break;
case 20.3:
$child = $row->value;
break;
case 21.3:
$preteen = $row->value;
break;
case 22:
$reservationtime = $row->value;
$wpdb->query( $wpdb->prepare(
“INSERT INTO temp_table_1 (lname, fname, phone, adults, preteen, child, reservationtime, paymenttype) VALUES ( %s, %s, %s, %s, %s, %s, %s, %s )”,
array(
$lname,
$fname,
$phone,
$adults,
$preteen,
$child,
$reservationtime,
$paymenttype
)
));
$lname = “”;
$fname = “”;
$phone = “”;
$adults = “”;
$preteen = “”;
$child = “”;
$reservationtime = “”;
$paymenttype = “”;
break;
default:
break;
}
}
}
//Set up our query to query rows from the WordPress temp_table_1 table.

$query = “SELECT
lname,
fname,
phone,
adults,
preteen,
child,
reservationtime,
paymenttype
FROM temp_table_1
ORDER BY reservationtime, lname, fname”;

//Run the Query

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

if($result)
{
foreach($result as $key => $row)
{
$lname = $row->lname;
$fname = $row->fname;
$phone = $row->phone;
$adults = $row->adults;
$preteen = $row->preteen;
$child = $row->child;
$reservationtime = $row->reservationtime;
$paymenttype = $row->paymenttype;
echo “

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

Name Phone Number Adults Pre-Teens Children Reservation Time Payment Type
” . $lname . “, ” . $fname . “ ” . $phone . “ ” . $adults . “ ” . $preteen . “ ” . $child . “ ” . $reservationtime . “ ” . $paymenttype . “