Combobox Mysql PHP Codigniter

0

Hello

I would like the help of you, I am a beginner in programming and I can not solve it.

I have a form to register PRODUCTS, in this form has a combobox to select which is the supplier of the product. this combobox is populated with data from the vendor table. In the PRODUCTS table, it is necessary to save the name of the vendor id, that is, when selecting a vendor in the combo, save your name and id.

For example:

<select id="idFornecedor" name="idFornecedor">
    <option>Selecione</option>
    <?php 
        $sql ="SELECT * FROM fornecedores ORDER BY nomeFornecedor";
        $resultado =mysqli_query($conn, $sql);
        while($dados = mysqli_fetch_assoc($resultado)){
    ?>
        <option value="<?php echo $dados["idFornecedor"]; ?>"><?php echo $dados["nomeFornecedor"];?></option>
    <?php
    }
</select>

This is working fine, but it only writes the idFormers, after all is what is set in the value option of the combobox, now besides the idlers I need the name of the selected vendor to write to another field of the PRODUCT table, I tried to do with a input type hidden but I'm not able to

    
asked by anonymous 16.04.2018 / 18:28

0 answers