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

  • SEARCH
  • Home
  • 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 7815725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:36:36+00:00 2026-06-02T05:36:36+00:00

So i’m filling in for our developer at the moment (be for-warned i’m a

  • 0

So i’m filling in for our developer at the moment (be for-warned i’m a beginner) but I”m trying to simply sort my search results by profiles that have a profile picture included (i.e, i don’t want blank profile pictures to show up at the top of the results…they should all be at the end of the results)…Note that there are a couple user types which is why there is so much code…

I’m pretty sure where i’m going wrong is the 2 lines…

ORDER BY $order u.picture ISNULL DESC”; (which relates to ordering by profile pictures). Would really appreciate any and all help…thx!

The code is as follows:

if ($user_type == 1) {
        $sql = "SELECT a.*, u.*,
                (SELECT COUNT(DISTINCT userId) FROM LF_usertype_A WHERE usertype_BId = u.userId AND status = 1) as i_cnt,
                (SELECT COUNT(productId) FROM LF_products WHERE userId = u.userId AND status = 1) as product_cnt,
                (SELECT COUNT(transactionId)
                    FROM LF_Transactions
                    WHERE usertypeBId = u.userId
                        AND (status = 1 OR status = 2)
                        AND type = 9
                        AND userId != usertypeBId
                        AND userId != usertypeAId) AS cnt
                FROM LF_Users u
                JOIN LF_products a ON a.userId = u.userId
                LEFT JOIN LF_Transactions t ON t.productId = a.productId
                WHERE a.status = 1
                    AND u.status = 1
                    AND u.userType = :ut $where
                GROUP BY u.userID
                ORDER BY $order u.name DESC LIMIT 200";
    } elseif ($filter != "recent" && $user_type == 2) {
        $sql = "SELECT u.*,
                (SELECT COUNT(a.productId) FROM LF_usertypeA a INNER JOIN LF_products ON a.productId = m.productId INNER JOIN LF_Users uu ON uu.userId = a.usertypeAId WHERE a.userId = u.userId AND uu.status = 1 AND a.status = 1 AND m.status = 1) as product_cnt,
                (SELECT COUNT(transactionId)
                    FROM LF_Transactions
                    WHERE usertypeBId = u.userId
                        AND (status = 1 OR status = 2)
                        AND type = 9
                        AND userId != usertypeAId
                        AND userId != usertypeBId) AS cnt
                FROM LF_Users u
                LEFT JOIN LF_Transactions t ON t.usertypeBId = u.userId
                WHERE u.status = 1
                    AND u.userId != 1
                    AND u.userType = :ut $where
                GROUP BY u.userID
                ORDER BY $order u.name DESC LIMIT 200
                ORDER BY $order u.picture ISNULL DESC";
    } else {
        $sql = "SELECT u.*,
                (SELECT COUNT(a.productId) FROM LF_usertype_A a INNER JOIN LF_products m ON a.productId = m.productId INNER JOIN LF_Users uu ON uu.userId = a.usertypeAId WHERE a.userId = u.userId AND uu.status = 1 AND a.status = 1 AND m.status = 1) as product_cnt,
                (SELECT COUNT(transactionId)
                    FROM LF_Transactions
                    WHERE usertypeBId = u.userId
                        AND (status = 1 OR status = 2)
                        AND type = 9
                        AND userId != usertypeAId
                        AND userId != usertypeBId) AS cnt
                FROM LF_Users u
                WHERE u.status = 1
                AND u.userId != 1
                AND u.userType = :ut $where
                GROUP BY u.userID
                ORDER BY $order u.name DESC LIMIT 200
        ORDER BY $order u.picture ISNULL DESC";
    }
  • 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-02T05:36:38+00:00Added an answer on June 2, 2026 at 5:36 am

    You would have to put the isnull condition before your regular sort order if you want it to take precedence:

    ORDER BY ISNULL(u.picture), $order
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

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.