lundi 8 février 2016

PHP how to combine multiple if-statements into one function

Currently based on checkbox value,form will add subscribers to corresponding list but cant save more than one value.

How to merge in order to select and save more than one checkbox value?

if(isset($_POST['checkbox_list']) && in_array('Austin Metro', $_POST['checkbox_list'])){
    $listID = '3';
    if ($listID){
        $indeed_mail->indeed_wysija_subscribe( $listID, $email );
    }
    break;
} else if(isset($_POST['checkbox_list']) && in_array('Central Austin', $_POST['checkbox_list'])){
    $listID = '4';
    if ($listID){
        $indeed_mail->indeed_wysija_subscribe( $listID, $email );
    }
    break;
} else if(isset($_POST['checkbox_list']) && in_array('Georgetown', $_POST['checkbox_list'])){
    $listID = '5';
    if ($listID){
        $indeed_mail->indeed_wysija_subscribe( $listID, $email );
    }
    break;
}

Aucun commentaire:

Enregistrer un commentaire