echo "<div class=messagess>";
$msg=$db->query("SELECT * FROM `messages` WHERE `recipient`='{$_SESSION['id']}'");
while($r=mysqli_fetch_array($msg)){
$users=$db->query("SELECT * FROM `users` WHERE `id`='{$r['author']}'");
while($r2=mysqli_fetch_array($users)){
$avatar=select('background', 'avatar', 'id', $r['author'], true);
if($r2['id']==2){?>
<script>
$(document).ready(function() {
$('.ava').addClass('mm');
});
</script>
<?php }
echo "<a href=/messages?type=private&id=".$r2['id'].">";
echo "<div class=user>";
echo "<img class=ava src=".photo($avatar[0])."><br>";
echo "<b><h2 class=nick>".$r2['nickname']."</h2></b>";
echo '<span class=ms>'.$r['message'].'</span>';
echo "</div>";
echo '</a>';`
.mm{
border: 4px solid green;
}
<?php
...
$style = '';
if( $r2['id'] == 2 ) {
$style = 'mm';
}
echo "<img class='$style' src=".photo($avatar[0])."><br>";
...