Current location: Hot Scripts Forums » Programming Languages » PHP » Top 10 Rating


Top 10 Rating

Reply
  #1 (permalink)  
Old 05-12-04, 05:03 PM
djnaf's Avatar
djnaf djnaf is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Post Top 10 Rating

hello
i'm trying to put a top 10 pages viewed in my website
supose its a joke site
the jokes is saved in MySQL, and there is a coloum in the table called counter, when ever a joke is viewed the counter increase one.

i thought of making a for loop to to sort the jokes according to the most viewed joke, and then display a TOP 10 table.

but i didnt know how to do it, how to display the top 10.
or if there is another way to do this.

i hope you can help me people
Reply With Quote
  #2 (permalink)  
Old 05-13-04, 01:31 AM
djnaf's Avatar
djnaf djnaf is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by djnaf
hello
i'm trying to put a top 10 pages viewed in my website
supose its a joke site
the jokes is saved in MySQL, and there is a coloum in the table called counter, when ever a joke is viewed the counter increase one.

i thought of making a for loop to to sort the jokes according to the most viewed joke, and then display a TOP 10 table.

but i didnt know how to do it, how to display the top 10.
or if there is another way to do this.

i hope you can help me people
Why no one interested!!!!
Reply With Quote
  #3 (permalink)  
Old 05-13-04, 03:23 PM
altlprsn altlprsn is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
I am interested, unfortunately I can't help you...

Good luck...
Reply With Quote
  #4 (permalink)  
Old 05-14-04, 05:36 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
to do this, use ORDER BY..
so this how the SQL query should look:
Code:
SELECT * FROM jokes ORDER BY counter DESC LIMIT 10;
change 'counter' to the column name you have!

this query should fetch 10 jokes sorted desceding by counter..

Quote:
Why no one interested!!!!
chill out!
help isn't always avilable in the same day of posting the problem
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #5 (permalink)  
Old 05-16-04, 10:15 AM
Klesti Klesti is offline
Newbie Coder
 
Join Date: May 2004
Location: Albania
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
use this code:
PHP Code:

$sql "SELECT * FROM jokes ORDER BY counter DESC LIMIT 10";

$result mysql_query($sql);
while (
$row mysql_fetch_assoc($result)) {
//put here the displaying link code

Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Top 10 list Wowhownow Script Requests 0 05-02-04 08:18 PM
is it a good idea to run 23 search expressions? lordmerlin ASP 1 03-24-04 04:05 PM
Top 50 by rating Wowhownow PHP 6 03-21-04 12:14 AM
Hi, it's me with a rating script again ^_^; miki PHP 3 12-30-03 07:37 AM
help me find a working rating system darkcarnival PHP 2 06-28-03 12:30 PM


All times are GMT -5. The time now is 10:32 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.