In a table unit, I have 18 columns which can contain one of three different values in each of the columns. The possible values are 'N', 'I' or 'ETP'.
Three of those columns are:
|------------|-------------|------------|
|gcc_1_1 |gcc_1_2 |gcc_1_3 |
|------------|-------------|------------|
I want to return counts of each of those three values for each column to put into their own variables, e.g. the following variables would be for the first column and the three possible values.
$gcc_1_1_n
$gcc_1_1_i
$gcc_1_1_etp
What would be the simplest way of achieving this in PHP using one MySQL query?
$query = "SELECT * FROM unit";
$result = $connection->query( $query );
while ($row = mysqli_fetch_array($result)) {
...
}