Skip navigation
Currently Being Moderated

Manual sorting of search results

Jun 21, 2012 7:44 AM

Tags: #php #database #mysql #sort_order #search_results #order_by

Is there a way to sort results manually without having to build stupidly complex arrays?

 

I need to sort initially in a very specific way like so:

 

Beer

Orange Juice

 

(then by A-Z)

 

Apple Juice

Brandy

Carrott Juice

Blah blah blah through to Z

 

Is it possible to do this even if I have to add the products in order manually?

 

I'm using PHP and MySQL.

 

Thank you.

 
Replies
  • Currently Being Moderated
    Jun 21, 2012 10:17 AM   in reply to matthew stuart

    I came across this extension of Tom Muck

    http://www.tom-muck.com/extensions/help/SortRepeatRegion/

     

    I never used it myself.

    I used other extensions of Tom Muck an they were OK.

     

    Best Regards,

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 2:23 PM   in reply to matthew stuart

    How about creating a new column called 'sortfield'.  Assign 'aaa' to Beer and 'aab' to Orange Juice. For the rest of the items populate it with the same value as DrinkType. You could create a trigger to do that for you. Then just sort on the sortfield.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points