私はphpでいいねシステムを作成しています。投稿IDを使用して投稿を気に入った人のすべてのユーザー名を取得するコードがあり、投稿が気に入らなかった場合は、投稿のように言うボタンが表示されます。そうでない場合は、投稿とは異なるというボタンが表示され、いいねがない場合は、「誰もその投稿を最初に気に入った人はいません」と表示されます。しかし、それを追加すると、複数の人が投稿を気に入っていても、ユーザー ID は 1 つしか取得できません。これを修正するにはどうすればよいですか。コードは次のとおりです。
$fancy = $db->fetch("SELECT * FROM " . $prefix . "_fancy WHERE post_id = '" . $post_row['id'] . "' ORDER BY id");
if ($fancy) {
$name = $user->name($fancy['account_id']);
if ($account['id'] !== $fancy['account_id']) {
$fancytext = '<div>'.$name.' Like this post.<!-- BEGIN logged_in --> <a href="./?area=forum&s=topic&t='.$topic_id.'&f='.$pid.'"><img src="./template/default/images/like.png" alt="" border="0"/></a><!-- END logged_in -->
</div>';
} else {
$fancytext = '<div>'.$name.' Like this post.<!-- BEGIN logged_in --> <a href="./?area=forum&s=topic&t='.$topic_id.'&unf='.$pid.'"><img src="./template/default/images/unlike.png" alt="" border="0"/></a><!-- END logged_in -->
</div>';
}
} else {
$fancytext = '<div><i>No one has liked this post, be the first!</i> <!-- BEGIN logged_in --><a href="./?area=forum&s=topic&t='.$topic_id.'&f='.$pid.'"><img src="./template/default/images/like.png" alt="" border="0"/></a><!-- END logged_in -->
</div>';
}