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 6634185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:54:01+00:00 2026-05-25T22:54:01+00:00

I currently have an ads listing site on which there are 3 ordering filters.

  • 0

I currently have an ads listing site on which there are 3 ordering filters. By default, the ads are sorted with the following line:

    $this->setState('filter_order', $app->getUserStateFromRequest('com_adsman.filter_order','filter_order', "start_date"));

When I change the start_date to another column name, it sorts by that column by default, so I know that’s where the change needs to be done. Now, how would I go about displaying random results, based on the above piece of code?

Thanks!

Edit: Here is where the actual query is called.

            $Orderings[]    = "`a`.$filter_order $filter_order_Dir";
    $Orderings[]    = "`a`.`id` $filter_order_Dir ";        

$query = " SELECT ".implode(",",$SelectCols)." \r\n ".

     " FROM `#__ads` AS `a` \r\n".

     implode(" \r\n ",$JoinList)."\r\n".

     $where."\r\n".

     " GROUP BY `a`.`id` ".

     " ORDER BY ".implode(",",$Orderings)." \r\n "; 

I’m thinking of using something like

$rand = rand(.implode(“,”,$SelectCols));

and changing $filter_order to $rand..I know this is not going to work tho, wrong syntax and wrong everything, this is where I need help!

  • 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-05-25T22:54:01+00:00Added an answer on May 25, 2026 at 10:54 pm

    well, since the query is created somewhere else, and only filled with the parameters coming from this line … you can’t just change this line …

    find the actual query … append a new column like “rand() as random” and change “start_date” to “random” in this line …

    //edit:

    $query = " SELECT ".implode(",",$SelectCols).",rand() as random \r\n ".
         " FROM `#__ads` AS `a` \r\n".
         implode(" \r\n ",$JoinList)."\r\n".
         $where."\r\n".
         " GROUP BY `a`.`id` ".
         " ORDER BY ".implode(",",$Orderings)." \r\n "; 
    

    should give you a random column named “random” (of course, if there is already a column with that name, that would be trouble … so maybe choose a unique name instead of “random”)

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

Sidebar

Related Questions

Currently i have a working PHP edit script, which allows users to edit ads
I currently have a table of concentrations, which are linked to a table of
I currently have a webview that displays a current site. However, it cuts off
Some Context: We currently have 5 versions of our site (US, UK, CA, AU,
I have a classifieds website, and I have currently around 100thousand ads in a
I have a classifieds website which uses SOLR to search for whatever ads the
I have the following query that returns < 300 results. It is currently taking
I currently have this jquery but it won't work. if it helps my url
I currently have this piece of code to insert a new row, use validation
Currently have a drop down menu that is activated on a hover (from display:none

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.