How to pull the Option value of the select HTML property that is saved in MYSQL

0

How do I change and save in the database, as soon as I update the saved value in the box, the way I am saving in the database, but when updating the page it leaves the box always filled with the first value.

   $ifs = "SELECT * FROM config WHERE id='1'";
   $sqs = mysqli_query($conn, $ifs);
   $sda = mysqli_fetch_assoc($sqs);

   if (isset($_POST['aspect'])){


    $atext = mysqli_real_escape_string($conn,$_POST['aspect']);

    $sql = "UPDATE 'config' SET 'aspect' = '$atext' WHERE 'id' = 1";
    $ssl = mysqli_query($conn, $sql);

    header("Location: settings-jw.php");
    exit();

   }

<form  action="" method="post" >
   <div class="col-sm-12 col-lg-4">
      <div class="form-group">
         <label for="aspect">Aspect Ratio:</label> <i class="fa fa-info-circle" data-toggle="tooltip" title="Aspect ratio"></i>
         <select id="aspect" name="aspect" class="form-control">
            <option value="16:9">16:9</option>
            <option value="4:3">4:3</option>
         </select>
      </div>
   </div>
   <input type="submit" class="btn btn-danger" value="Salvar" />
</form>
    
asked by anonymous 01.09.2018 / 19:22

1 answer

0

You would need to add some conditions in your select to this. Example:

<option <?php if($sda['aspect'] == '16:9') echo 'selected' ?> value="16:9">16:9</option>
    
02.09.2018 / 05:21