Juno Fernando Juno Fernando - 3 months ago 13x
SQL Question

PHP update data from dropdown

how to update selected data from dropdown to mysql (mysql update) using php?

<select name="maintenance_mode">
<option>Maintenance On</option>
<option>Maintenance Off</option>
<button type="submit" name="update">Apply</button>

The i set column type to tinyint(1). basically just update 0 or 1.


You should use value 0/1 in select options

        $connct = mysqli_connect('localhost','root','password','database');
        $value = $_POST['maintenance_mode'];
        $result = mysqli_query($connct,"UPDATE table_name SET filedname = '$value'");

<form method="post" action="">
<select name="maintenance_mode">
  <option value="1">Maintenance On</option>
  <option value="0">Maintenance Off</option>
<input type="submit" name="update" value="update">