General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old January 1st, 2003, 09:20 AM
DivaX007 DivaX007 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 23 DivaX007 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Who's the Top Three?

win98, localhost, php4+, register globals off, mysql

i have a site that allow you to rate individual photos.

i need to get the top three scores in the database and display them on index.php. what is the simplest way to accomplish this?
this is what i have in the db

post_id|numVotes|votes|rating

thanks in advance.

Reply With Quote
  #2  
Old January 1st, 2003, 10:01 AM
skgera skgera is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 3 skgera User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
sort rating DESC and then just print the first three rows. should work

Reply With Quote
  #3  
Old January 1st, 2003, 02:05 PM
hadley hadley is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 63 hadley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Or you could use limit

Hadley

Reply With Quote
  #4  
Old January 1st, 2003, 05:37 PM
skgera skgera is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 3 skgera User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ooops ... i knew that i forgot something

Reply With Quote
  #5  
Old January 1st, 2003, 08:13 PM
DivaX007 DivaX007 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 23 DivaX007 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
1. let me clarify what i should have said in the last post:
"i need to get the <b>top three</b> by: <b>Rating</b> in the database and display them on index.php."

forgot to say in original post: along with getting the top three by:<b>Rating</b> i need to get the <b>pic_title</b> of the photo.

my table contains <b>many many</b> fields, but the relevant ones are perhaps :

post_id|pic_title|numVotes|votes|Rating

2. i've already read the links that you gave and have not found them newbie-friendly.

any suggestions that you have to help me with this problem would be appreciated. i'm probably making it more complicated than it is

Reply With Quote
  #6  
Old January 1st, 2003, 11:53 PM
DivaX007 DivaX007 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 23 DivaX007 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ok. i have this so far:

<?php

$query = "SELECT Rating FROM pm_weblog ORDER BY Rating DESC LIMIT 0,3";

$result = mysql_query($query);

$count_rows = mysql_num_rows($result);

for($y=1; $y<=$count_rows;$y++) {

$topthree = mysql_fetch_array($result);

echo "$y. $topthree[0]";
}
?>

but it gives me this:
1. 72. 63. 6 (which,btw, is 1.7 2.6 3.6)

problem:
1. these are from the numVotes column (the number of times each item has been voted on) instead of the Rating column.
2. in addition these are simply the first three rows, not the rows with the highest values

my table contains <b>many many</b> fields, but the relevant ones are perhaps :

post_id|pic_title|numVotes|votes|Rating

anyone?...

Reply With Quote
  #7  
Old January 3rd, 2003, 11:42 AM
DivaX007 DivaX007 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 23 DivaX007 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i started new and got it to work. thanks all.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Who's the Top Three?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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 not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway