Join repeated results - PHP [duplicate]

1

Good morning everyone, I have a question to join repeated results in the query in Mysql made by PHP.

This is the code that I'm using at the moment it removed the first retry of values in the query, but there is another field that should also be removed from the duplicates, I've tried several combinations that I understand and nothing went right, it's returning this way:

Cliente Tipo Análise
   1      1    0001
          1    0002
---------------------
   2      1    0100

And I want to do this:

Cliente Tipo Análise
   1      1    0001
               0002
---------------------
   2      1    0100

Notice that in the Type field, you are repeating the values.

I have N clients, and this client has N analyzes, I can not repeat the client in the search, nor the type, because it will put everything together in the Analysis part, forming a list.

The code I'm currently using:

$query = mysqli_query( $db, 'SELECT * FROM laudos ORDER BY cliente, tipo');
$cli = array();

while($row = $query->fetch_assoc()) {
    $cli[$row['cliente']][] = $row;
}
?>

<table border="1" cellpadding="10">
<tr>
    <td>Cliente</td>
    <td>Tipo</td>
    <td>Análises</td>
</tr>
<?php 
    foreach($cli as $cliente => $values){
?>
<tr>
    <td><?php echo $cliente; ?></td>
    <?php foreach($values as $resul) { ?>
    <tr>            
        <td></td>
        <td>
            <?php echo $resul['tipo'];?>
        </td>
        <td>
            <select>
                <option SELECTED>Escolha um laudo</option>
                <option><?php echo $resul['legisla'].'-'.$resul['numero'];}?></option>
            </select>
        </td>
    </tr>
</tr>
    <?php } ?>
    
asked by anonymous 14.09.2015 / 13:56

1 answer

0

Good try to be clearer, I can not comment.

do you want to use combobox with the values it?

because of doing so $ cli [$ row ['client']] [] = $ row;

The correct form is $ rows ['table name'] = $ row; or $ rows [] = $ row; to remove all bd fields

    
14.09.2015 / 14:08