2
I have the table that registers a user (gr_entity) and has a link with a user status table (gr_entidade_status). I want the editing form (editando_user.php) to show the value that is in the database, but allow me to see the other items that are in the table (gr_entidade_status) so I can edit.
Note: The connection to the database and post method is working perfectly.
Below is the select that picked the user to present 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 I define, appears the value that is in the database. In the case for this code would be value ='<?php echo $usuario ['id_entidade_tipo'] ?>'
Below follows the status field. In this case, I made a select exclusively in the status table (gr_entidade_status) to give me the value of the name (status)
<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 wonder how I can do to be executed properly
I recommend migrating to mysqli, since mysql has become obsolete in newer versions of php: https://answall.com/questions/579/por-que-n%C3%A3o-devo-usar-fun%C3%A7%C3%B5es-do-tipo-mysql
– Francisco
But how would I use the current version? Because I can’t change yet, I have to restructure everything.
– Robson Freitas
It will be almost the same, there are few changes. I recommend taking a look at the official documentation of php.
– Francisco
There is a "soup" of letters, it is not clear what you want. From what I understand you want to show all the status of existing processes, in an html select tag, and then leave selected a specific status. Only the part
$usuario ['id_entidade_tipo']
does not seem to have any relation. Need to detail better.– Juven_v
This field is inside the gr_entity table , which receives the status code.
– Robson Freitas
Please disregard this field with the type information, consider it as if it were id_entidade_status
– Robson Freitas