Hi, I'm creating a website where users can liket things and by liking things you'll see people who have liked the same thing on your home page. Now, currently my code shows people who like ONE same thing as you, but how would I make it so that if anyone has multiple things that they like that you also like, they'll show up first? So basically it will rank the people based on how many things they like that you like.
<?php
$liked_query = mysqli_query ($link, "SELECT whats_liked FROM whatilike WHERE user_liked_by='$user' ORDER BY id ASC LIMIT 10");
$num_rows_liked = mysqli_num_rows ($liked_query);
if ($num_rows_liked !=0) {
while ($fetch_row = mysqli_fetch_assoc ($liked_query)) {
$thing_liked = $fetch_row ['whats_liked'];
$people_like = mysqli_query ($link, "SELECT user_liked_by FROM whatilike WHERE whats_liked LIKE '%$thing_liked%' && user_liked_by !='$user'");
while ($rpl = mysqli_fetch_assoc ($people_like)) {
$person_like_u = $rpl ['user_liked_by'];
$pluq = mysqli_query ($link, "SELECT profile_pic FROM users WHERE username='$person_like_u'");
while ($pluqr = mysqli_fetch_assoc ($pluq)) {
$pli = $pluqr ['profile_pic'];
echo "<a href='profile.php?u=$person_like_u'><img src='data/user_photos/$pli' height='50px' width='50px'
style='border-radius:400px;'></a>";
?>
Btw I deleted all the styling from this code to make it easier for you all to read.