使用php基于sql查询使类动态化

Im trying to make the <a> class dynamic based on a sql query. Lets say the sql is:

SELECT status FROM tbl_person;
while($row = $stmt->fetchObject()){ ?>
<a class="btn-sm"><?php echo $row->status?></a>

and I have this wrong code where it should add another <a> class that changes the color.

if($(this).val() == "happy"){   
    $('a').addClass('btn-yellow');
}
else if($(this).val() == "sad"){
    $('a').addClass('btn-blue');
}
else if($(this).val() == "normal"){
    $('a').addClass('btn-white');
}

Please help