vendredi 29 janvier 2021

PHP UNDEFINED VARIABLE on SELECT is there any better way to do this?

Is there any better way doing this without having an error if $personal_info['reg_civil_status'] and $_POST['reg_civil_status'] is empty? Because I'm having an "Undefined Variable Error"

                    <b>Civil Status: </b>
                    <select class="controler-1" name="reg_civil_status">
                        <?php 
                            foreach($civil_status_opt as $civil_status_opt){
                                if($personal_info['reg_civil_status'] == $civil_status_opt || $_POST['reg_civil_status'] == $civil_status_opt) {
                                    echo "<option selected='selected' value='$civil_status_opt'>$civil_status_opt</option>";
                                }
                                else {
                                    echo "<option value='$civil_status_opt'>$civil_status_opt</option>";
                                }
                            }
                        ?>
                    </select>



Aucun commentaire:

Enregistrer un commentaire