Task: there are several columns nam1, nam2 - in them the numbers from 1 to 30, which are repeated.

It is necessary to count the number of repetitions of each number and display the result in two columns - the number, the number of repetitions. We have the following entry:

$query="SELECT nam1, COUNT(*) AS total FROM lottoindex WHERE nam1 > 0 GROUP BY nam1"; $rs = mysql_query($query); while($row = mysql_fetch_array($rs)) { echo $rs; echo $row['nam1']; echo '<br>'; } 

Displays the result:

 Resource id #5 1 Resource id #5 10 Resource id #5 11 Resource id #5 12 ... 

Tell me, please, what is the problem and how to do it right?

    1 answer 1

      echo $rs; echo $row['nam1']; echo '<br>'; 

    change to

      echo $row['nam1']; echo $row['total']; echo '<br>'; 
    • That's right, but it counts only from the nam1 column how to make it display the type Number1 = nam1 + nam2 ... - Jeka