PHP - Receive the ID of a value via select option $ _POST

0

Good afternoon guys, I've been developing a code and packaged a part.

I need to get a value to register it as fkid from a table.

I have this part of the code:

    <td><h3>Vincular Conteudo</h3></td>
    <td colspan="2"><select name="tipoConteudo" class="form-control">
    <?php
        $tipoConteudo = new ConteudoDAO($conexao);
        foreach($tipoConteudo->listaNomeConteudo() as $tipo) : 
    ?>
            <option value="<?=$tipo['nomeConteudo']?>"> 
                <?=$tipo['nomeConteudo']; ?> 
            </option> 
        <?php 
        endforeach
        ?>

This part of the code works perfectly. It demonstrates a dropdown of what I need. But I need to send the linked id to the "nameName", which belongs to the table contents. I'm going to demonstrate the function listNameCount below:

function listaNomeConteudo() {
    $conteudos = array();
    $query = "select * from conteudo";
    $resultado = mysqli_query($this->conexao, $query);

   while($conteudo = mysqli_fetch_assoc($resultado)){
        array_push($conteudos, $conteudo);
    }
    return $conteudos;
}

All I need is to get the ID of the row name, and link to a new table as fkid.

Would anyone help me? Obrigaod

    
asked by anonymous 01.09.2018 / 23:19

1 answer

1

In this part:

<option value="<?=$tipo['nomeConteudo']?>"> 
                <?=$tipo['nomeConteudo']; ?> 
            </option> 

Why are you passing 'filename' in value? Why not pass the ID?

    
02.09.2018 / 05:14