There are many ways to do this in fact, but if you are going to use any additional information, then we or not, the user liked what select * is a bad idea. The reason is because you are asking the database to return the value of each column in this table.
, , , , , . , , , , , , .
.
$userid=$_COOKIE['userid'];
$sql = "SELECT count(user_id) as total FROM likes WHERE `user_id`='{$userid}'";
$query = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($query);
if( $row ['total'] > 0){
echo "unlike";
}
else{
echo "like";
}
, .