skip to Main Content

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


  1. Chosen as BEST ANSWER

    Got it working - changed the option text

    from

    <option value="Clinic 1"<? if($data['formClinic']=="Clinic 1") echo("selected="selected"");?>>Clinic 1</option>
    

    to

    <option value="Clinic 1" <?php if($data['formClinic']=="Clinic 1") echo 'selected="selected"';?>>Clinic 1</option> 
    

    for all options


  2. code used to work, but then I updated my php version

    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.inis.

    ; short_open_tag
    ;   Default Value: On
    ;   Development Value: Off
    ;   Production Value: Off
    

    (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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search