Problem in Sorting two resultset..

Discussion in 'PHP' started by ashishhbti, Oct 8, 2007.

  1. #1
    I ave a problem in sorting two resultset..
    Supoose we have a follwing field in database..

    id name vote type

    1 ashish 2 1
    2 ashish 4 2

    i want to select top 5 records(according to vote) of type 1 and top voted 5 records of type 2 ....
    then want to show on page these 10 records on sorting order according to vote ..

    any suggestion ??

    Please help me...

    Thanks
    Ashish...
     
    ashishhbti, Oct 8, 2007 IP
  2. tamen

    tamen Peon

    Messages:
    182
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    There is probably an easier way. But here goes.
    Merge each name with the votes => 2_ashish & 4_ashish and put those in a array and sort() them (http://php.net/manual/en/function.sort.php)

    After that you can explode('_', $array) the array and get them split up into names and votes again.

    A bit hackish, but it should work. I haven't tested it though, so beware, it might kill your dog ;)
     
    tamen, Oct 8, 2007 IP