Jump to content

Need query help to place priority on display of search results


simcoweb

Recommended Posts

I'm creating a directory of nationwide lenders of which can elect to be shown in the Top 3 of the results for their category. I have a field in the 'members' table for top_3 with the value being either 1 for no or 0 for yes, that they are not in/in the top 3. So, what I want to do is in my query for displaying the results of the search is place a priority on those that qualify, show them in the top 3..then the remainder below that. This would be similar to the 'sponsored' links you see in many directories.

 

I just have a snippet of the query as a starter:

<?php
$sql = "SELECT * FROM amember_members WHERE is_lender='0' AND category='$category' AND loan_type='$loantype' 
AND loan_amount='$loanamount' ORDER BY top_3";
?>

 

So, the query should pull all results matching certain criteria (loan amount, loan type, etc.) THEN prioritize the display IF the lender is designated in the top 3. I searched around for something on this but couldn't find anything specific.

Link to comment
Share on other sites

First, as always, thanks for the posts!

 

Ok, the 0's should be on top. I guess what I thought would happen is the 0's would display and then nothing else after the 0's ran out. Simple logic running through my simple mind.

 

display 0's

1's don't display cuz they ain't 0's

 

So, if i'm getting the jist of your comments, it will display ALL the results but just prioritize to the 0's then when those run out displays the 1's automatically.

Link to comment
Share on other sites

If you only want to display results where `top_3` is 0, add that to your search parameters:

 

<?php
$sql = "SELECT * FROM amember_members WHERE is_lender='0' AND category='$category' AND loan_type='$loantype' 
AND loan_amount='$loanamount' AND top_3 = 0";
?>

 

Or have i misunderstood?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.