Juno Fernando Juno Fernando - 1 year ago 81
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.

Answer Source

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">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download