I am trying to populate an HTML table with mysql data, I have the following data in MySQL: / P> I want to create a table that shows a list of references and how often Is: What I tried was: But it does not mention each person separately, as well as a new table row for each entry, even though the reunion was similar. Any help is too big to appreciate. You might be searching for keyword for , select COUNT (*), it will give you the exact table without any additional loop for you Want php
id, ip, referral
ID, IP, referral 1 1.1.1.1 google.com 2 2.2.2.2 google.com 3 3.3.3.3 Test Comm 4 4.4.4.4 Other dot output:
google.com 2 test.com 1 another.com 1
& lt; Table class = "table-table-barbed table-primary" & gt; & Lt; Tbody & gt; & Lt ;? Php $ sql = "select traffic from *"; $ Result = mysql_query ($ SQL); ? & Gt; & Lt ;? Php while ($ row = mysql_fetch_array ($ result)) {? & Gt; & Lt; Tr & gt; & Lt; Td square = "tc" & gt; Font face = "aerial, helvetica, non-serif" & gt; & Lt ;? Php if ($ row ['referal'] == '') {echo "blank referrals"; } Else {echo $ row ['referal']; } & Gt; & Lt; / Font & gt; & Lt; / TD & gt; & Lt; Td square = "tc" & gt; & Lt; Center & gt; & Lt; Font face = "aerial, helvetica, non-serif" & gt; & Lt ;? Php $ referal = $ row ['referal']; $ Sql = "Select COUNT (*) traffic from WHERE referal = $ referal"; $ Num_rows = mysql_num_rows ($ result); Repeat "$ num_rows"; ? & Gt; & Lt; / Font & gt; & Lt; / Center & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt ;? Php}? & Gt; & Lt; / Tbody & gt; & Lt; / Table & gt;
GROUP BY SQL: < From the Traffic Group, from the / p>
referral,