icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » Select the rating with most rates.

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old November 21st, 2005, 6:30 PM   #1 (permalink)
Registered User
Comfy Contributor
 
Daniel_Hatcher's Avatar
 
Joined in Dec 2004
Lives in United Kingdom
Hosted on pass74
146 posts
Gave thanks: 1
Thanked 1 Time in 1 Post
Select the rating with most rates.

Now i have five of these $rating_count_ = mysql_num_rows($query_rating_);

each with the numbers 1 to 5 after the _ now these select the amount of ratings so i have like so


1: 3 votes
2: 4 votes
3: 1 vote
4: 6 votes
5: 10 votes

Nowe what i need is a way for it to check all of the number of rows like

$rating_count_1 = mysql_num_rows($query_rating_1);
$rating_count_2 = mysql_num_rows($query_rating_2);
$rating_count_3 = mysql_num_rows($query_rating_3);
$rating_count_4 = mysql_num_rows($query_rating_4);
$rating_count_5 = mysql_num_rows($query_rating_5);

and find the one with the most rows then display the number for it. IE. because theres 10 votes on the rating 5 it will display 5.
__________________
http://residentfantasy.com
Daniel_Hatcher is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 21st, 2005, 8:58 PM   #2 (permalink)
H
after g, before i
Resident.
 
H's Avatar
 
Joined in Jul 2004
Lives in N,BC,CA
8,087 posts
Gave thanks: 48
Thanked 131 times
Couldn't you put each into an array and then do an array rsort?

PHP Code:
<?php
$rating_count 
= array();
$rating_count[0] = mysql_num_rows($query_rating_1);
$rating_count[1] = mysql_num_rows($query_rating_2);
$rating_count[2] = mysql_num_rows($query_rating_3);
$rating_count[3] = mysql_num_rows($query_rating_4);
$rating_count[4] = mysql_num_rows($query_rating_5);
rsort($rating_count);
?>

Last edited by H; November 21st, 2005 at 8:59 PM.. Reason: Realized you'd want rsort rather than sort.
H is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 26th, 2005, 9:33 PM   #3 (permalink)
Registered User
Comfy Contributor
 
Daniel_Hatcher's Avatar
 
Joined in Dec 2004
Lives in United Kingdom
Hosted on pass74
146 posts
Gave thanks: 1
Thanked 1 Time in 1 Post
No, that never worked just showed a 1.
__________________
http://residentfantasy.com
Daniel_Hatcher is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 27th, 2005, 5:46 PM   #4 (permalink)
DemonicAngel
Super #1
 
twirp's Avatar
 
Joined in Aug 2004
Lives in Wherever The World Takes Me
Hosted on Pass76
1,847 posts
Gave thanks: 28
Thanked 35 times
You could do a bubble sort...
Link
__________________
You wear Vans so high school kids will think that you can skate. He wears Vans because he can skate. TwiRp wears Vans because they were on sale. Pass76 wants Vans.
twirp is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On