Let User Sort mysql query results by LIKE items in mysql?

Discussion in 'MySQL' started by webavt, Dec 9, 2007.

  1. #1
    Hey all,

    I'm not sure if this is possible, but I would like your help if it is. I've scoured all my books and can't figure out the best way to do this.

    1. I have a listing of articles and the user can click on a title heading to sort by article, category, etc...

    Once they click on a title heading and it goes in ascending order for that column, how do you let them click the same heading and have it go to descending order?

    2. Each article has a category associated with it (and other attributes author, date, etc..). I want the user to be able to click on one of those sub-attributes and be able to only show the items that are in that attribute.

    I'm thinking that somehow I can use the MYSQL "LIKE" statement, but the user won't click on a category/attribute until after the information is already output.

    Example:

    Title | Author | Category | Date

    Article title 1 | Author's Name 1 | Category Here 1 | date/year (2007)
    Article title 2 | Author's Name 1 | Category Here 2 | date/year (2007)
    Article title 3 | Author's Name 2 | Category Here 1 | date/year (2006)

    Partial MYSQL statement: where type LIKE $type

    $type would equal whatever the item was from the query results and would check what they clicked by using GET. So if the user clicked on one of the author's names above it would show only the items in the database with that author's name...

    Any ideas would be greatly appreciated.

    Thanks,

    Jon
     
    webavt, Dec 9, 2007 IP