Mysql result sorting

Discussion in 'PHP' started by zoomzoomzoom, Oct 25, 2010.

  1. #1
    Hey guys,

    Sorry if my title is not so clear,but here's what I'm trying to do:

    I have car model table and I'm creating html drop down from names. Problem though is that some models are repeating because of different generations and I can't keep these in different tables because of database structure. So I'm getting results like:
    1. Integra
    2. CL
    3. CL
    4. MDX
    5. NSX

    This is not good for my dropdown I need something like:
    1. Integra (1)
    2. CL (2)
    3. MDX (1)
    4. NSX (1)

    Could somebody help me out in this. I know I did it once sometime ago, but don't have access to code and I guess am too old to remember:D
     
    zoomzoomzoom, Oct 25, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
  3. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #3
    danx10, Oct 25, 2010 IP
  4. silviuks

    silviuks Peon

    Messages:
    43
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    you can use DISTINCT in your select query.
     
    silviuks, Oct 26, 2010 IP
  5. Sparaker

    Sparaker Peon

    Messages:
    204
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Simply group the naming field in your SQL query and get the count of that value and you can show it in brackets. post your sql if you want i can do it for you.
     
    Sparaker, Oct 26, 2010 IP