Values in DataList HTML, PHP, MYSQL


I would like to know why 'my datalist stores a number in my database instead of a name.

Let me explain.

I have a database with a table CLIENTS with fields: Customer, customername

I load the DataList with the clients that are in the BD and I save them in another table called FERTILIZERS with fields: id_abono, customername

  $query = "SELECT * FROM clientes";
  $result2 = mysqli_query($connect, $query);

     <input list="browsers" name="myBrowser"  class="form-control form- 
    <datalist id="browsers" >

        while ($valores = mysqli_fetch_array($result2)) {
  <option value=$valores['idcliente']>$valores['nombrecliente'].</option>


  </datalist> <br>

appears to me:

The problem I have is that when I select one of the displayed values, the number (idcliente) appears and I need the name (clientname) to be stored in my FERTILIZERS table

asked by Nor 13.11.2018 в 20:37

1 answer


For the time being, the solution that I see but that does not convince me is to put the customer name in the VALUE attribute and pass it as the idClient parameter.

answered by 14.11.2018 в 04:34