Edit select showing bank value and showing other table options

2
  

I have the table that registers a user (gr_entidade) and that has a connection with a user status table (gr_entidade_status). I want the edit form (editing_user.php) to display the value in the database, but I can see the other items in the table (gr_entity_status) so I can edit it.

Note: The connection to the database and method post is working perfectly.

Below is the select that picks up the user to display his information

 $sql = " SELECT * FROM gr_entidade ent
         JOIN gr_entidade_status status on ent.id_entidade_status = status.id_entidade_status
         JOIN gr_entidade_tipo tipo on ent.id_entidade_tipo = tipo.id_entidade_tipo WHERE id_entidade =  " . $_GET['id'];
$conn = mysql_query($sql);
$usuario = mysql_fetch_array($conn);

Then the $ user variable along with the field that I define, shows the value that is in the database. In case for this code it would be value ='<?php echo $usuario ['id_entidade_tipo'] ?>'

Below is the status field. In that case, I made a select exclusively in the status table (gr_entity_status) to give me the status value

  <label class="control-label">*Staus</label>
     <select class="form-control" name="id_entidade_status">
        <?php
           $result = mysql_query("SELECT * FROM gr_processo_status");
               while ($row = mysql_fetch_array($result)) {                               
         ?>
          <option value="<?php echo $row['id_status_processo']?>"> <?php echo $row['status']?></option>
          <?php
                 }
             ?>
   </select>
  

I would like to know how I can do to run correctly

    
asked by anonymous 28.12.2017 / 14:51

1 answer

1

I was able to do the following:

 <select class="form-control" name="id_entidade_tipo">
                                                        <?php
                                                          $result = mysql_query("SELECT * FROM gr_entidade_tipo");
                                                          while ($row = mysql_fetch_array($result)) {                               
                                                          ?>
                                                        <option value="<?php echo $row['id_entidade_tipo']?>" <?php if( $usuario['id_entidade_tipo'] == $row['id_entidade_tipo']){?>selected<?php } ?>> <?php echo $row['tipo_entidade']?></option>
                                                         <?php
                                                         }
                                                         ?>
                                                    </select>
    
02.01.2018 / 18:26