Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

insert database with <select>

I would have to insert values ​​into a database from this . My problem is that the value I have to enter is not $prov, but $id.The item the user should see is $prov. How could I do?

while ($row=mysqli_fetch_assoc($result)) {
   $id=$row['id_prov'];
   $prov=$row['n_provi'];
   echo '<option value="'.$id.'">'.$prov.'</option>';

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Your php program reads your database and generates a SELECT field something like this:

<select name="xxx" id="xxx">
    <option value="1">Prov1</option>
    <option value="2">Prov2</option>
</select>

When you submit the form containing that field, the field’s value comes from the value of the option your user chose.

You can put anything you want in the values of options. I think you want this.

<select name="xxx" id="xxx">
    <option value="Prov1">Prov1</option>
    <option value="Prov2">Prov2</option>
</select>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading