Why isn't my if-statement not triggering?

The object of this is to first print buttons based on groups fetched from database table for groups. After selecting a group, it should allow you to select a driver from that group in the dropout menu. I've tested the $kops for fecthing driver result, it works. The button selecting the group ID works too. But somehow, I cannot compare the group ID from the button to the group ID from the driver database table. If I remove the if statement, it show all the drivers, regardless of group they are assigned in.

<script>
function getTab(clicked_id) {
var x = clicked_id;
document.getElementById("work").innerHTML = x;
    }
</script>

Above is the script that fetches an group ID from a button. The buttons are generated upon group ID's, and their amount is based on how many are in the database. Reason why there are no static, hardcoded buttons.


$tab_in = '<p id="work"></p>' ;

A variable to store the group ID from the button


   while($kops = mysqli_fetch_assoc($driver_rslt)){
     if ($tab_in === $kops['opsryhma']){
   echo'<option value="';echo $kops['ops_id']; echo'">'; echo $kops['opsnimi']; echo'</option>';
   

And in here, the previously mentioned group ID is compared to a another group ID fetched from another table in the database. THE PROBLEM: that first group ID does not appear to be working here. I can echo $tab_in it above the option and it will print out the right ID, but it will not appear inside the if statement for the comparison.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum