How to put value in select

0

My select looks like this:

Nome do carro:<br>
<input type="text" name="nomeCarro" value="<?php echo $dados['nome']; ?>"><br>
Marca:<br>
<select name="marcas">
  <option value="Toyota">Toyota</option>
  <option value="Volkswagen">Volkswagen</option>
  <option value="Bmw">Bmw</option>
  <option value="Honda">Honda</option>
  <option value="Ford">Ford</option>
  <option value="Hyundai">Hyundai</option>
</select>

Ano:<br>
<input type="numeric" name="ano" value="<?php echo $dados['ano']; ?>"><br>
<br><br>
<input type="submit" value="Atualizar">

The question is: How do I bring the value of select, since I've brought it from others too.

    
asked by anonymous 01.05.2017 / 19:05

1 answer

0

Suppose you should have a table just to allocate the values of the tags.

I believe you already use related tables . Then you should have saved only the tag ID in the table where you are looking for these values, so you should create a method to return the name according to the ID.

[] s.

<select name='marcas'>
   <?php
       foreach($dados['marcas'] as $value)
       {
          echo '<option value="'.$value.'">'.Retornar::nomeMarca($value).'</option>;
       }
   ?>
</select>
    
01.05.2017 / 21:26