i have a radio button which could be selected on an infinite amount of rows as it adds a new row everytime the first one is completed, the user then selects which one they want to be the primary number which set it as a value "1" or "2" etc..
my issue is if the user where to enter more than 8 phone numbers my code would be obsolete i was wondering what the best way to do this was :
if ($paymentDetails['MakePrimary'] == 1){
$voipCustomer->StdCode = $paymentDetails['phoneNumber'][0]['stdCode'];
$voipCustomer->Number = $paymentDetails['phoneNumber'][0]['mainNumber'];
} else if ($paymentDetails['MakePrimary'] == 2){
$voipCustomer->StdCode = $paymentDetails['phoneNumber'][1]['stdCode'];
$voipCustomer->Number = $paymentDetails['phoneNumber'][1]['mainNumber'];
} else if ($paymentDetails['MakePrimary'] == 3){
$voipCustomer->StdCode = $paymentDetails['phoneNumber'][2]['stdCode'];
$voipCustomer->Number = $paymentDetails['phoneNumber'][2]['mainNumber'];
} else if ($paymentDetails['MakePrimary'] == 4){
$voipCustomer->StdCode = $paymentDetails['phoneNumber'][3]['stdCode'];
$voipCustomer->Number = $paymentDetails['phoneNumber'][3]['mainNumber'];
} else if ($paymentDetails['MakePrimary'] == 5){
$voipCustomer->StdCode = $paymentDetails['phoneNumber'][4]['stdCode'];
$voipCustomer->Number = $paymentDetails['phoneNumber'][4]['mainNumber'];
} else if ($paymentDetails['MakePrimary'] == 6){
$voipCustomer->StdCode = $paymentDetails['phoneNumber'][5]['stdCode'];
$voipCustomer->Number = $paymentDetails['phoneNumber'][5]['mainNumber'];
} else if ($paymentDetails['MakePrimary'] == 7){
$voipCustomer->StdCode = $paymentDetails['phoneNumber'][6]['stdCode'];
$voipCustomer->Number = $paymentDetails['phoneNumber'][6]['mainNumber'];
} else if ($paymentDetails['MakePrimary'] == 8){
$voipCustomer->StdCode = $paymentDetails['phoneNumber'][7]['stdCode'];
$voipCustomer->Number = $paymentDetails['phoneNumber'][7]['mainNumber'];
} else {
$voipCustomer->StdCode = $paymentDetails['phoneNumber'][8]['stdCode'];
$voipCustomer->Number = $paymentDetails['phoneNumber'][8]['mainNumber'];
}
Aucun commentaire:
Enregistrer un commentaire