for ($i = 0; $i < count($lnames); $i++) { if (empty($lnames[$i]) && empty($fnames[$i])) { continue; } $cust->personNum($count); $cust->FirstName($fnames[$i]); $cust->LastName($lnames[$i]); $cust->BlueLine($cust->CardNo() . ' ' . $cust->LastName()); $cust->save(); // save next personNum $count++; } // remove names that were blank on the form for ($i = $count; $i < 5; $i++) { $cust->personNum($i); $cust->delete(); } $meminfo = new MeminfoModel($dbc); $meminfo->card_no($memNum); $meminfo->street($MI_FIELDS['street']); $meminfo->city($MI_FIELDS['city']); $meminfo->state($MI_FIELDS['state']); $meminfo->phone($MI_FIELDS['phone']); $meminfo->email_2($MI_FIELDS['email_2']); $meminfo->email_1($MI_FIELDS['email_1']); $meminfo->ads_OK($MI_FIELDS['ads_OK']); $meminfo->save(); $memdate = new MemDatesModel($dbc); $memdate->card_no($memNum); $memdate->start_date($_POST['startDate']); $memdate->end_date($_POST['endDate']);