Home > other >  how to show items on top whose vote value is greater then others php array
how to show items on top whose vote value is greater then others php array

Time:04-05

i hade made a PHP code that is showing all servers.. so I had a column called votes. I want to show array servers serial by serial like server1 has 10 votes and server2 has 9 votes so the server1 will be at the top and server2 will be after server1 how to do it? thank you.

here's the code I have..


$test = new Servers;

$test->additional_where("AND `private` = '0' AND `active` = '1' AND `highlight` = '0'");

$test->remove_pagination();

$test->display();

i had made a php code thats showing servers from mysql db perfectly.. i just wanted a thing like the server whom have top vote show him top and who has less vote like one server has 10 vote show him at top and second one has 20 show him after that server.. how to do it? thank you..

CodePudding user response:

Sounds like you need to sort the results. You'll need to add something like below to your query:

ORDER BY votes DESC

CodePudding user response:

HEY I TRIED THIS $test->additional_where("AND `private` = '0' AND `active` = '1' AND `highlight` = '0' AND ORDER BY votes DESC"); AND NOW NO SERVER IS SHOWING..

  • Related