Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8101365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:57:53+00:00 2026-06-05T22:57:53+00:00

I have those code snippet that checks the fans table and gets everyone who

  • 0

I have those code snippet that checks the fans table and gets everyone who has fanned you. It then checks if you have fanned them as well and if so it displays their username and profile picture.

It check if you have fanned them using $count I’m assuming this is where it’s tripping up. but firebug isn’t showing any errors.

<?php $friendlist = mysql_query("SELECT * FROM fans WHERE username='$user'") or die(mysql_error());
        while($row = mysql_fetch_array($result1)) {
            $friendname = $row['fanned'];
            $friendlist2 = mysql_query("SELECT * FROM fans WHERE username='$friendname' AND fanned='$user'") or die(mysql_error());
            $count = mysql_num_rows($friendlist2);
            if($count == 1 ){
                $avatar = mysql_query("SELECT * FROM users WHERE username='$friendname'") or die(mysql_error());
                while($row3 = mysql_fetch_assoc($avatar)) {
                $filename = $row3['avatar'];
                if($filename != "") { 
                            $friendpic = '<img id="headeravapic" src="profileavatars/' . $friendname . "/" . $filename . '" />';
                        }
                        else {
                            $friendpic = '<img id="headeravapic" src="images/nopic.PNG" />';
                        }
        echo '<div align="center" id="onlinepic">' . $friendpic . '<p />' . $friendname . '</div>'; 
                }
            }
        }?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:57:54+00:00Added an answer on June 5, 2026 at 10:57 pm

    You can simplify this into one query. Something like:

    SELECT f.*, u.avatar, f2.username as YouFanThem
       FROM fans f
           LEFT JOIN fans f2 ON f.fanned=f2.username and f2.fanned='$user'
           LEFT JOIN users u ON f.fanned=u.username
       WHERE f.username='$user'
    while($row = mysql_fetch_array($result1)) { 
        $FriendName = $row['fanned'];
        $Avatar = $row['avatar'];
        $MutualFriend = (empty($row['YouFanThem']) ? false : true);
    }
    

    If you want to restrict to ONLY those where you are mutual fans, then change the “LEFT JOIN” to an “INNER JOIN” – then you also don’t need the “YouFanThem” in the return result.

    I’d also encourage you not to use “SELECT *” as it’s heavy, select just the fields you need.

    Finally, the obligatory note that mysql_functions are being depreciated, so check out PDO instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a project that generates a code snippet that can be used on
I have some default values for testing my code, but for security reasons those
So I have these lines of javascript code that I need to remove all
I have a quite strange issue. Please, look at these screenshots: Code of that
I have the following code snippet.. I get the error Expected identifier, string or
I have some Scala code that does something nifty with two different versions of
In my little code snippet below I have a wrapper class for a simple
I have two weird workflows that I'm able to fix.. I fixed them by
I have the following snippet of code of which I do not have access
I have code similar to the snippet below (taken from http://leastprivilege.com/2009/05/24/use-geneva-session-management-for-your-own-needs/ ) public class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.