mercredi 25 juillet 2018

First check value before we put it into an if statement

I have a form with the following select inputs:

In the first file:

    <select class="form-control" name="city" id="city">
        <option value="--">--</option>
        <option value="breda">Breda</option>
    </select>

    <select class="form-control" name="interior" id="interior">
        <option value="--">--</option>
        <option value="gestoffeerd">Gestoffeerd</option>
    </select>

In the second file: In this file I retrieve values of an api as $result.

    $city= ucfirst($_POST['city']);
    $interior= ucfirst($_POST['interior']);

    if($city != '--'){
      $isset_city = $city;
    }

    if($interior != '--'){
      $isset_interior = $interior;
    }

    if(isset($isset_city) == $result['city'] && isset($interior) == $result['interior']){
      // When not isset city then I will retrieve all values that is equal to interor
      // When not isset interor then I will retrieve all values that is equal to city
      // When not isset city and not isset interor then al will retrieve all values 
    }

How to do it? I don't really know

Aucun commentaire:

Enregistrer un commentaire