I have the following php generated table (drawing from sql database values) in which I want the first column (all the usernames) to be frozen (fixed) while the user can scroll horizontally and 'right' across the page to view the scores for each user.
I cannot figure out how to do this with the mix of php and html going on. Can anyone suggest a viable solution please?
An image for illustration purposes is below
(I wish for the username column (all rows) to be fixed) while scrolling through to the right - there will be many more quizzes)
 will be many more quizzes)
PHP and HTML Code
 <tbody>
                    <?php foreach(@$result as $record){?>
                    <tr>
                        <td><?php echo $record["username"];?></td>
                            <?php
                            $counter=0;
                            while(mysqli_num_rows($all_quizes) > $counter){
                                $current_td = mysqli_query($con,"SELECT * FROM quiz_takers WHERE username='".$record["username"]."' AND quiz_id=".$quizes[$counter][0]." ORDER BY marks DESC");
                                $td = mysqli_fetch_array($current_td);
                                if($td['percentage'] == null){
                                    echo "<td>-</td>";
                                }else{
                                    if(intval($td["percentage"]) >= 0 && intval($td["percentage"]) <= 30){
                                        $color = 'red';
                                    }elseif(intval($td["percentage"]) > 30 && intval($td["percentage"]) <= 70){
                                        $color = '#ffbf00';
                                    }elseif(intval($td["percentage"]) <= 30){
                                    }else{
                                        $color = 'green';
                                    }
                                    echo "<td style='color:".$color."'>".round($td["percentage"],2)."%</td>";
                                }
                                $counter++;
                            }
                            /*foreach($current_td as $td){
                                echo $counter." ".$td['username'] . " - ".$quizes[$counter]['3']."<br>";
                                if($quizes[$counter]['0'] == $td['quiz_id']){
                            ?>
                            <td><?php echo $td["percentage"];?></td>
                            <?php  } $counter++;}*/ ?>
                    </tr>
                        <?php  } ?>
                    </tbody>
UPDATE:
What I have tried, thanks to the helpful suggestion below regarding CSS is the following: It works, but not quite (messed up formatting)
CSS
<style type="text/css">
.headcol {
  position: absolute;
  width: 5em;
  left: 0;
  top: auto;
  border-top-width: 1px;
  /*only relevant for first row*/
  margin-top: -1px;
  /*compensate for top border*/
}
.headcol:before {
  content: 'Row ';
}
        </style>
Added this line below:
<tbody>
                    <?php foreach(@$result as $record){?>
                    <tr>
                        <td><th class="headcol"><?php echo $record["username"];?></th></td>
                            <?php
                            $counter=0;
                            while(mysqli_num_rows($all_quizes) > $counter){
                                $current_td = mysqli_query($con,"SELECT * FROM quiz_takers WHERE username='".$record["username"]."' AND quiz_id=".$quizes[$counter][0]." ORDER BY marks DESC");
                                $td = mysqli_fetch_array($current_td);
                                if($td['percentage'] == null){
                                    echo "<td>-</td>";
                                }else{
                                    if(intval($td["percentage"]) >= 0 && intval($td["percentage"]) <= 30){
                                        $color = 'red';
                                    }elseif(intval($td["percentage"]) > 30 && intval($td["percentage"]) <= 70){
                                        $color = '#ffbf00';
                                    }elseif(intval($td["percentage"]) <= 30){
                                    }else{
                                        $color = 'green';
                                    }
                                    echo "<td style='color:".$color."'>".round($td["percentage"],2)."%</td>";
                                }
                                $counter++;
                            }
                            /*foreach($current_td as $td){
                                echo $counter." ".$td['username'] . " - ".$quizes[$counter]['3']."<br>";
                                if($quizes[$counter]['0'] == $td['quiz_id']){
                            ?>
                            <td><?php echo $td["percentage"];?></td>
                            <?php  } $counter++;}*/ ?>
                    </tr>
                        <?php  } ?>
                    </tbody>
HTML Result is skewed: comes up with this

instead of the desired:

