|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
sort rating DESC and then just print the first three rows.
should work ![]() |
|
#4
|
|||
|
|||
|
ooops ... i knew that i forgot something
![]() |
|
#5
|
|||
|
|||
|
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 ![]() |
|
#6
|
|||
|
|||
|
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?... |
|
#7
|
|||
|
|||
|
i started new and got it to work. thanks all.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Who's the Top Three? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|