Descending order displaying wrong result, please help me...

Discussion in 'MySQL' started by RahulSaini, Oct 11, 2012.

  1. #1
    i create this Query:
    
    	$query_big_collection      = "select name,image,wallpapers,current_wallpapers,views from $wallpapers_list ORDER BY `current_wallpapers` DESC limit 0,6";
    	$get_big_collection        = mysql_query($query_big_collection);
    	  if(! $get_big_collection){ error_data(); }
    	    else
    	  {
    	    echo "<h2>Biggest Collections:<br></h2><table width=505 align=center><tr><td>";
    	    while($show_big_collection = mysql_fetch_array($get_big_collection, MYSQL_ASSOC))
    		{
    		 echo "<div style='display:inline;' class=img><a href='{$show_big_collection['wallpapers']}' title='{$show_big_collection['name']}'><img alt='{$show_big_collection['name']}' src='{$show_big_collection['image']}'/><div class=desc>{$show_big_collection['name']}</div></a></div>";
    		}
    	    echo "</td></tr></table>";
    	  }
    
    
    function error_data()
    	{echo "<h1 align=center>Oops!<br>Something Wrong With this Page. Please Refresh or Contact us if you are facing same problem.</h1>";}
    
    PHP:
    Its Displaying Wrong Result.. like as

    1st 88 Views
    2nd 83 Views
    3rd 798 Views
    4th 762 Views
    5th 7 Views
    6th 68 Views


    and i want to display it like this:

    1st 798
    2nd 762
    3rd 88
    4th 83
    5th 68
    6th 7


    Please Help me, How do i fix this..?
    i know if i put 007,068,083,088 then the result will be printed right but I can't Change anything in "Viewes" Column because it will be added through "count(id)"

    Thanks For Any Help!
     
    Solved! View solution.
    RahulSaini, Oct 11, 2012 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    You need to order by whatever column 798, 762, 88 etc are in.

    "select name,image,wallpapers,current_wallpapers,views from $wallpapers_list ORDER BY `current_wallpapers` DESC limit 0,6";

    Cheange the current_wallpapers to views I think.

    You must be missing some code in what you pasted or something though. The code you posted would not produce anything but a list of names.
     
    jestep, Oct 12, 2012 IP
  3. RahulSaini

    RahulSaini Well-Known Member

    Messages:
    222
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    123
    #3
    Thanks but i want to display it according to current wallpapers.
    maximum wallpapers collection will be displayed first then lower and then lower.....

    Yes i don't write whole query here... Its too big...
    Another suggetions....??
     
    RahulSaini, Oct 12, 2012 IP
  4. Alam

    Alam Active Member

    Messages:
    316
    Likes Received:
    91
    Best Answers:
    0
    Trophy Points:
    68
    #4
    If I have got your problem, please change your query:

    select name,image,wallpapers,current_wallpapers,views from $wallpapers_list ORDER BY `views` DESC limit 0,6
     
    Alam, Oct 14, 2012 IP
  5. RahulSaini

    RahulSaini Well-Known Member

    Messages:
    222
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    123
    #5
    here is same Problem in views..

    5
    50
    57
    3
    34
    1

    Now Please Tell me.... This order is not working...
     
    RahulSaini, Oct 14, 2012 IP
  6. alaufias

    alaufias Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #6
    try LIMIT Capital is not Samul

    
    
    select name,image,wallpapers,current_wallpapers,views from $wallpapers_list ORDER BY `current_wallpapers` DESC LIMIT 0,6
    
    PHP:
     
    alaufias, Oct 14, 2012 IP
  7. RahulSaini

    RahulSaini Well-Known Member

    Messages:
    222
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    123
    #7
    not working, same result
     
    RahulSaini, Oct 14, 2012 IP
  8. sekhar203

    sekhar203 Active Member

    Messages:
    96
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #8
    interesting and a knowledgeable thread...
     
    sekhar203, Oct 14, 2012 IP
  9. #9
    "LIMIT" only interested in the number of results displayed:pSo doesn't matter in your problem ,

    The first point :which column responsible of results .
    The second point : Make sure type of this column "int" = current_wallpapers must be "int" type not "text" or "VARCHAR".

    Regards
     
    Last edited: Oct 14, 2012
    alaufias, Oct 14, 2012 IP
  10. RahulSaini

    RahulSaini Well-Known Member

    Messages:
    222
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    123
    #10
    YES, its Working.....
    i was using "longtext" data type
    Thanks Friend... i waste my so many hours but not did it and You Solved my Problem....
    Thanks Again...!!!!
     
    RahulSaini, Oct 14, 2012 IP