Self Assessment Output

<div class="self-ass-instructions">
    <h2>Self-Assessment Output</h2>
    <p>This is your style</p>
</div>
<?php
    $counter_column_1 = 0;
    $counter_column_2 = 0;
    $counter_column_3 = 0;
    $counter_column_4 = 0;
?>
<div class="horizontal-scroll">
<table>
    <tr>
        <th></th>
        <th>
            Expressor
        </th>
        <th>
            Driver
        </th>
        <th>
            Amiable
        </th>
        <th>
            Analytical
        </th>
    </tr>
    <tr>
        <td>A</td>
        <td class=<?php if ( $_POST['A'] == "A-2" ) {
            echo "checked";
            $counter_column_1 = $counter_column_1 + 1;
        } ?>>
            a futurist            
        </td>
        <td class=<?php if ( $_POST['A'] == "A-3" ) {
            echo "checked";
            $counter_column_2 = $counter_column_2 + 1;
        } ?>>
            a realist
        </td>
        <td class=<?php if ( $_POST['A'] == "A-4" ) {
            echo "checked";
            $counter_column_3 = $counter_column_3 + 1;
        } ?>>
            a coordinator
        </td>
        <td class=<?php if ( $_POST['A'] == "A-1" ) {
            echo "checked";
            $counter_column_4 = $counter_column_4 + 1;
        } ?>>
            a reporter
        </td>
    </tr>
    <tr>
        <td>B</td>
        <td class=<?php if ( $_POST['B'] == "B-4" ) {
            echo "checked";
            $counter_column_1 = $counter_column_1 + 1;
        } ?>>
            forward-thinking
        </td>
        <td class=<?php if ( $_POST['B'] == "B-3" ) {
            echo "checked";
            $counter_column_2 = $counter_column_2 + 1;
        } ?>>
            values-focused
        </td>
        <td class=<?php if ( $_POST['B'] == "B-1" ) {
            echo "checked";
            $counter_column_3 = $counter_column_3 + 1;
        } ?>>
            people-oriented
        </td>
        <td class=<?php if ( $_POST['B'] == "B-2" ) {
            echo "checked";
            $counter_column_4 = $counter_column_4 + 1;
        } ?>>
            detail-focused
        </td>
    </tr>
    <tr>
        <td>C</td>
        <td class=<?php if ( $_POST['C'] == "C-1" ) {
            echo "checked";
            $counter_column_1 = $counter_column_1 + 1;
        } ?>>
            a dreamer
        </td>
        <td class=<?php if ( $_POST['C'] == "C-2" ) {
            echo "checked";
            $counter_column_2 = $counter_column_2 + 1;
        } ?>>
            a driver
        </td>
        <td class=<?php if ( $_POST['C'] == "C-4" ) {
            echo "checked";
            $counter_column_3 = $counter_column_3 + 1;
        } ?>>
            a peacekeeper
        </td>
        <td class=<?php if ( $_POST['C'] == "C-3" ) {
            echo "checked";
            $counter_column_4 = $counter_column_4 + 1;
        } ?>>
            a doer
        </td>
    </tr>
    <tr>
        <td>D</td>
        <td class=<?php if ( $_POST['D'] == "D-2" ) {
            echo "checked";
            $counter_column_1 = $counter_column_1 + 1;
        } ?>>
            inspiring
        </td>
        <td class=<?php if ( $_POST['D'] == "D-3" ) {
            echo "checked";
            $counter_column_2 = $counter_column_2 + 1;
        } ?>>
            reliable
        </td>
        <td class=<?php if ( $_POST['D'] == "D-4" ) {
            echo "checked";
            $counter_column_3 = $counter_column_3 + 1;
        } ?>>
            considerate
        </td>
        <td class=<?php if ( $_POST['D'] == "D-1" ) {
            echo "checked";
            $counter_column_4 = $counter_column_4 + 1;
        } ?>>
            decisive
        </td>
    </tr>
    <tr>
        <td>E</td>
        <td class=<?php if ( $_POST['E'] == "E-4" ) {
            echo "checked";
            $counter_column_1 = $counter_column_1 + 1;
        } ?>>
            has sense of mission
        </td>
        <td class=<?php if ( $_POST['E'] == "E-1" ) {
            echo "checked";
            $counter_column_2 = $counter_column_2 + 1;
        } ?>>
            meets deadlines
        </td>
        <td class=<?php if ( $_POST['E'] == "E-2" ) {
            echo "checked";
            $counter_column_3 = $counter_column_3 + 1;
        } ?>>
            brings people together
        </td>
        <td class=<?php if ( $_POST['E'] == "E-3" ) {
            echo "checked";
            $counter_column_4 = $counter_column_4 + 1;
        } ?>>
            keep things on track
        </td>
    </tr>
    <tr>
        <td>F</td>
        <td class=<?php if ( $_POST['F'] == "F-1" ) {
            echo "checked";
            $counter_column_1 = $counter_column_1 + 1;
        } ?>>
            dramatic
        </td>
        <td class=<?php if ( $_POST['F'] == "F-4" ) {
            echo "checked";
            $counter_column_2 = $counter_column_2 + 1;
        } ?>>
            focused
        </td>
        <td class=<?php if ( $_POST['F'] == "F-3" ) {
            echo "checked";
            $counter_column_3 = $counter_column_3 + 1;
        } ?>>
            relaxed
        </td>
        <td class=<?php if ( $_POST['F'] == "F-2" ) {
            echo "checked";
            $counter_column_4 = $counter_column_4 + 1;
        } ?>>
            curious
        </td>
    </tr>
    <tr>
        <td>G</td>
        <td class=<?php if ( $_POST['G'] == "G-3" ) {
            echo "checked";
            $counter_column_1 = $counter_column_1 + 1;
        } ?>>
            knows where he or she wants to be
        </td>
        <td class=<?php if ( $_POST['G'] == "G-2" ) {
            echo "checked";
            $counter_column_2 = $counter_column_2 + 1;
        } ?>>
            knows what has to be done
        </td>
        <td class=<?php if ( $_POST['G'] == "G-1" ) {
            echo "checked";
            $counter_column_3 = $counter_column_3 + 1;
        } ?>>
            knows how things should be done
        </td>
        <td class=<?php if ( $_POST['G'] == "G-4" ) {
            echo "checked";
            $counter_column_4 = $counter_column_4 + 1;
        } ?>>
            knows what questions to ask
        </td>
    </tr>
    <tr>
        <td>H</td>
        <td class=<?php if ( $_POST['H'] == "H-2" ) {
            echo "checked";
            $counter_column_1 = $counter_column_1 + 1;
        } ?>>
            anticipates problems
        </td>
        <td class=<?php if ( $_POST['H'] == "H-3" ) {
            echo "checked";
            $counter_column_2 = $counter_column_2 + 1;
        } ?>>
            solves problems
        </td>
        <td class=<?php if ( $_POST['H'] == "H-4" ) {
            echo "checked";
            $counter_column_3 = $counter_column_3 + 1;
        } ?>>
            resolves conflicts
        </td>
        <td class=<?php if ( $_POST['H'] == "H-1" ) {
            echo "checked";
            $counter_column_4 = $counter_column_4 + 1;
        } ?>>
            reviews methods
        </td>
    </tr>
    <tr>
        <td>I</td>
        <td class=<?php if ( $_POST['I'] == "I-4" ) {
            echo "checked";
            $counter_column_1 = $counter_column_1 + 1;
        } ?>>
            focuses on outcomes
        </td>
        <td class=<?php if ( $_POST['I'] == "I-1" ) {
            echo "checked";
            $counter_column_2 = $counter_column_2 + 1;
        } ?>>
            gets results
        </td>
        <td class=<?php if ( $_POST['I'] == "I-3" ) {
            echo "checked";
            $counter_column_3 = $counter_column_3 + 1;
        } ?>>
            makes sure things are done right
        </td>
        <td class=<?php if ( $_POST['I'] == "I-2" ) {
            echo "checked";
            $counter_column_4 = $counter_column_4 + 1;
        } ?>>
            assures results are appropriate
        </td>
    </tr>
    <tr>
        <td>J</td>
        <td class=<?php if ( $_POST['J'] == "J-1" ) {
            echo "checked";
            $counter_column_1 = $counter_column_1 + 1;
        } ?>>
            charismatic
        </td>
        <td class=<?php if ( $_POST['J'] == "J-2" ) {
            echo "checked";
            $counter_column_2 = $counter_column_2 + 1;
        } ?>>
            prepared
        </td>
        <td class=<?php if ( $_POST['J'] == "J-3" ) {
            echo "checked";
            $counter_column_3 = $counter_column_3 + 1;
        } ?>>
            easy-going
        </td>
        <td class=<?php if ( $_POST['J'] == "J-4" ) {
            echo "checked";
            $counter_column_4 = $counter_column_4 + 1;
        } ?>>
            aware
        </td>
    </tr>
    
<?php
    // Start array
$grades = array(
    array('score' => $counter_column_1, "name" => "Expressor"),
    array('score' => $counter_column_2, "name" => "Driver"),
    array('score' => $counter_column_3, "name" => "Amiable"),
    array('score' => $counter_column_4, "name" => "Analytical")
  );

  rsort($grades);
  
  $i         = 0;
  $prevScore = 0;
  
  foreach ( $grades as &$grade ) {
    // Increment rank only if scores different
    if( $grade[ 'score' ] != $prevScore ){
      $i++;
    }
  
    $prevScore = $grade[ 'score' ];
    $grade[ 'rank' ] = $i;
  }
  
//   echo '<pre>';
//   print_r($grades);
//   echo '</pre>';

?>
<tr>
        <th></th>
        <th>
            Expressor<br>
            Total: <?php echo $counter_column_1; ?> <br>
            Rank: <?php 
                    foreach($grades as $key=>$value){
                        if($value['name'] == 'Expressor'){
                            echo $value['rank'];
                        }
                       }
                  ?>
        </th>
        <th>
            Driver<br>
            Total: <?php echo $counter_column_2; ?> <br>
            Rank: <?php 
                    foreach($grades as $key=>$value){
                        if($value['name'] == 'Driver'){
                            echo $value['rank'];
                        }
                       }
                  ?>
        </th>
        <th>
            Amiable<br>
            Total: <?php echo $counter_column_3; ?> <br>
            Rank: <?php 
                    foreach($grades as $key=>$value){
                        if($value['name'] == 'Amiable'){
                            echo $value['rank'];
                        }
                       }
                  ?>
        </th>
        <th>
            Analytical<br>
            Total: <?php echo $counter_column_4; ?> <br>
            Rank: <?php 
                    foreach($grades as $key=>$value){
                        if($value['name'] == 'Analytical'){
                            echo $value['rank'];
                        }
                       }
                  ?>
        </th>
    </tr>
</table>
</div>