Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select values from database and show in a dropdown menu? #31

Closed
vlori2k opened this issue Jul 9, 2020 · 1 comment
Closed

select values from database and show in a dropdown menu? #31

vlori2k opened this issue Jul 9, 2020 · 1 comment

Comments

@vlori2k
Copy link

vlori2k commented Jul 9, 2020

Hi, im not having any issues, i am just curious on how i can select data from DB and show in a bootstrap dropdown menu?

something like this:

<div class="form-group">
<label for="equipment_used">Equipment used?:</label>
    <select class="form-control" id="equipment_used" name="equipment_used" placeholder="Equipment used"  placeholder="Equipment used" class="form-control" id ="equipment_used">
        <option value="one">One</option>

        <?php echo "<option value=" .$equipment['equipment_name']. ">" .$equipment['equipment_name']. "</option>"; ?>

        <?php echo htmlspecialchars($row['equipment_name']); ?>
        <option value="<?php echo htmlspecialchars($equipment['equipment_name'], ENT_QUOTES, 'UTF-8'); ?>"
        <option value="<?=htmlspecialchars($equipment['equipment_name'], ENT_QUOTES, 'UTF-8'); ?>"><?=htmlspecialchars($equipment['equipment_name'], ENT_QUOTES, 'UTF-8') ?></option>
        <option value="two">Two</option>
    </select>
</div>
@vlori2k
Copy link
Author

vlori2k commented Jul 18, 2020

Solved it!

I did this:

  <div class="form-group">
        <label for="the_equipment_used">Equipment used?:</label>
        <select class="form-control" id="the_equipment_used" name="the_equipment_used" placeholder="Equipment for this sensor"  class="form-control" id ="the_equipment_used">

            <?php

            $db = getDbInstance();

            $get_all_equipment_IDs_and_names =($db->query("select equipment_ID, equipment_name FROM equipments "));


            foreach ($get_all_equipment_IDs_and_names as $key => $value) {

                echo "<option value='".$value["equipment_ID"]."'>".ucfirst($value["equipment_name"])."</option>";


            }

            ?>"

        </select>

    </div>

@chetans9 chetans9 closed this as completed Nov 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants