Group repeated data of a given column

0

I need to do a select and group the items, but as I have researched, my query will come from a database selected by a variable via post, and I will list the columns that are in a while coming via post from a variable as well.

The problem is to group the column that is in the while and its results !<br><br> (I add the columns dynamically so I can list more "easily" after the select, writing as field1, field2 and so on)

InthecaseoftheimageI'mselectingbyaspecificfieldandnotbythevariablecomingviaPOST.Thelistingproduct,side,etc...islistedbelowwithcolumnswithnamefield1,field2,etc.

ex.:

<p>::CadatreaUltimaCompradoCliente</p><?php$fila='grafica';//$_POST['bd'];$pega=$fila.'_lista';$mostrando=mysql_query("SELECT * FROM $pega order by cod asc " )or die (mysql_error());
    while ($vendo = mysql_fetch_array($mostrando)) {
$campo = $vendo['campo'];

        echo '<div class="_cliente">'.$campo.'</div>';
    }   

    ?>

    <select name="prods" class="input_prod" style="clear: left;">
<?php   
        $prod = mysql_query("SELECT campo1 FROM $fila group by campo1 order by cod asc ") or die(mysql_error());    
    while ($listar = mysql_fetch_array($prod)){

        $campo1 = $listar['campo1'];

        echo '<option value="'.$campo1.'" title="'.$campo1.'">'.$campo1.'</option>';
    }
        ?>

</select>

The above example is how I listed it in the submitted image, but I need to do a SELECT dynamically.

    
asked by anonymous 09.06.2018 / 03:20

0 answers