title: PHP show table from record with same id
body: <p>I want to return to the user a table that shows his orders but when a user orders one product the table is ok but in the moment that orders 2 product they get 2 lines with the same ID but different ProductID same total price.</p>
  <p><a href="https://i.stack.imgur.com/MraA6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MraA6.png" alt="enter image description here" /></a></p>
  <pre><code>$email = strval($_SESSION[&quot;email&quot;]); 
  $TabellaOrdini = &quot;SELECT DISTINCT ordini.IDOrdini, clienti.Indirizzo,       
                          clienti.Nome, clienti.Cognome, ordini.StatoConsegna, 
                          prodotti.Descrizione, ordini.TotaleOrdine, 
                          pacco.IDProdotti, pacco.Quantita
                  FROM (((clienti NATURAL JOIN ordini) 
                      JOIN pacco ON ordini.IDPacco = pacco.IDPacco) 
                      JOIN prodotti ON pacco.IDProdotti = prodotti.IDProdotti)
                  WHERE  clienti.IDClienti = ordini.IDClienti  
                  AND clienti.Email = '$email' 
                  ORDER BY ordini.IDOrdini&quot;;
  
  $CheckOrdini =   &quot;SELECT insertphpordini.IDOrdini, 
                      concat(insertphpordini.Descrizione,' x ',insertphpordini.Quantita) AS Risultato
                  FROM insertphpordini
                  WHERE insertphpordini.Email = '$email' 
                  AND insertphpordini.IDOrdini IN
                      ( SELECT insertphpordini.IDOrdini 
                        FROM insertphpordini
                        GROUP BY insertphpordini.IDOrdini
                        HAVING COUNT(IDOrdini)&gt;1
                      )&quot;;
  
  $result = $conn -&gt; query($TabellaOrdini);
  
  $result2 = $conn -&gt; query($CheckOrdini);
    
  echo &quot;&lt;table id='customers'&gt;&quot;;
      echo &quot;&lt;tr&gt;&lt;th colspan=7&gt;Ordini&lt;/th&gt;&lt;/tr&gt;&quot;;
      echo &quot;&lt;tr&gt;&quot;;
          echo &quot;&lt;td&gt;&lt;b&gt;IDOrdine&lt;/b&gt;&lt;/td&gt;&quot;;
          echo &quot;&lt;td&gt;&lt;b&gt;Nome&lt;/b&gt;&lt;/td&gt;&quot;;
          echo &quot;&lt;td&gt;&lt;b&gt;Cognome&lt;/b&gt;&lt;/td&gt;&quot;;
          echo &quot;&lt;td&gt;&lt;b&gt;Indirizzo&lt;/b&gt;&lt;/td&gt;&quot;;
          echo &quot;&lt;td&gt;&lt;b&gt;Stato Consegna&lt;/b&gt;&lt;/td&gt;&quot;;
          echo &quot;&lt;td&gt;&lt;b&gt;Prodotto&lt;/b&gt;&lt;/td&gt;&quot;;
          echo &quot;&lt;td&gt;&lt;b&gt;Totale Ordine&lt;/b&gt;&lt;/td&gt;&quot;;
          
  while($row = $result -&gt; fetch_assoc()) {
      echo &quot;&lt;tr&gt;&quot;;
      echo &quot;&lt;td&gt; $row[IDOrdini]&lt;/td&gt;&quot;;
      echo &quot;&lt;td&gt; $row[Nome]&lt;/td&gt;&quot;;
      echo &quot;&lt;td&gt; $row[Cognome] &lt;/td&gt;&quot;;
      echo &quot;&lt;td&gt; $row[Indirizzo] &lt;/td&gt;&quot;;
      echo &quot;&lt;td&gt; $row[StatoConsegna] &lt;/td&gt;&quot;;
      echo &quot;&lt;td&gt; $row[Descrizione] / $row[Quantita]&lt;/td&gt; &quot;;
      echo &quot;&lt;td&gt; $row[TotaleOrdine]€ &lt;/td&gt;&quot;;
      echo &quot;&lt;/tr&gt;&quot;;
  }
        
  echo &quot;&lt;/table&gt;&quot;;
  </code></pre>
  <p>the query $TabellaOrdini get all values from a user whit that email and the query $CheckOrdini get only the values with the same ID and concat the Description and quantity as Risultato.</p>
  <p>My goal is that is possible to have 1 order with 1 ID and in Product(row 6 from left of the table) have &quot;ProductName1/Quantity1, ProductName2/Quantity2&quot;</p>