Avoid repeating value in option value in php

0

Good morning, I am working with variables within option value, but I can not avoid repeated options, in the database the box field the information it contains is repeated but I do not know how to show it only once the information within the select and that the others are omitted, thank you very much.

<form role="form" name="caja" enctype="multipart/form-data" action="muestra_archivo.php" method="POST"> 

    <TR ALIGN=CENTER> 
        <th><label for="caja">Seleccionar caja: </label></th>
<?php
        $res1 = $mysqli->query($query);

?>   
<td><select name="caja">    
    <?php    
    while ( $rw = $res1->fetch_array() )    
    {   
        ?>  

        <option value="<?php echo $rw['caja']; ?>" >
        <?php echo $rw['caja']; ?>
        </option>

        <?php

    }  
    ?> 



</select>
</td>

<TD><input type="submit" value="Aceptar"></TD>
</form>
</TR>
</table>
    
asked by Stravos77 21.07.2016 в 18:26
source

2 answers

1

With the

 select DISTINCT caja FROM anytable

    
answered by 21.07.2016 / 18:47
source
1

Maybe if you do a GroupBy in the query by the box field you did the repetition of this one!

Result

    
answered by 21.07.2016 в 18:41