This code used to work, but then I updated my php version and the dropdown no longer echoes the current value. All of the other values echo and update correctly. The form shows the select options and when selected submits the updated clinic value correctly, so I am not including all of that code.
It’s probably something simple, but I can’t figure it out.
include "connect.php";
$id = $_GET['id'];
$qry = mysqli_query($conn,"select * from table where id='$id'");
$data = mysqli_fetch_array($qry);
if(isset($_POST['update']))
$Clinic = $_POST['formClinic'];
<select name="formClinic">
<option value="Clinic 1"<? if($data['formClinic']=="Clinic 1") echo(" selected="selected"");?>>Clinic 1</option>
<option value="Clinic 2"<? if($data['formClinic']=="Clinic 2") echo(" selected="selected"");?>>Clinic 2</option>
// and all of the rest of the update/close php stuff
2
Answers
Got it working - changed the option text
from
to
for all options
Well done, you’re on the right track! Now you have to compare the old with the new configuration and configure the updated PHP version accordingly so your code keeps on running – check your
php.ini
s.(example production php.ini and short open tags configuration in php-src)
Apart from PHP runtime configuration, the PHP manual also has additional information on migrating from one version to another, you can find those guides in the appendices.