Select do not duplicate information

0

I have a SELECT and what I want is that if there are two OPTIONS with the same value it just shows one.

As shown in the example below I have 2 Options with Micosoft and I just want it to show me an Option with Microsoft since I am listing this information from a database

<selectclass="form-control" id="inserir_fabricante2">
    <option value="" ></option>
        <?php
            $query_d = "SELECT * FROM reparacao ORDER BY fabricante ASC";
            $pv_d = (mysql_query($query_d));
                 while ($row_d = mysql_fetch_array($pv_d)){ ?>
                    <option value="<?php echo $row_d['fabricante']; ?>" ><?php echo  $row_d['fabricante']; ?></option>
                  <?php }   ?>
</select>
    
asked by anonymous 27.12.2017 / 04:05

1 answer

2

In this case, you can use SELECT DISTINCT, for example:

<select class="form-control" id="inserir_fabricante2">
<option value="" ></option>
    <?php
        $query_d = "SELECT DISTINCT fabricante FROM reparacao ORDER BY fabricante ASC";
        $pv_d = (mysql_query($query_d));
             while ($row_d = mysql_fetch_array($pv_d)){ ?>
                <option value="<?php echo $row_d['fabricante']; ?>" ><?php 
        echo  $row_d['fabricante']; ?></option>
              <?php }   ?>
</select>

To learn more about SELECT DISTINCT

    
27.12.2017 / 04:10