Bring data in Select with PHP

Asked

Viewed 106 times

-1

Good night...

I have a patient record. I need to bring the doctor who was selected by the SELECT component. For inclusion is ok. But in case I seek for a certain patient to make change I have to bring the selected doctor and that can also show other doctors in select if I wish to make change... I am programming in PHP... How do I do this ? I stand by

Roger

  • you want to show all doctors on select and leave selected what the patient is related to that?

  • Hi good afternoon... Yes, that’s right..

1 answer

0

you would have already taken the patient’s data, you would have the doctor’s code that treats that pagient, then just see to go through: first selects all doctors and makes an if that is the doctor you place at the beginning

     echo "<select id=\"medico\">";
   $sql = " Select nomeMedico,id from medicos";
     $query = $mysqli->query($sql);
  while( $linha = mysqli_fetch_array($query)){
     // caso o codigo que estava no paciente for igual ao do medico atual tu marca
     if($codMed == $linha['id']){
        echo "<option value=\"$linha['id']\" selected=\"selected\">$linha['nomeMedico']</option> ";
     }else{
         echo "<option value=\"$linha['id']\">$linha['nomeMedico']</option> ";
     }

  }
  • Hi Gabriella, Following your guidelines, I did so:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.