redho home | products | services

Programming Forums


Community for Java, PHP, Perl C, ASP and Python programmers

Ask your IT question here

problems with sql query


Goto page 1, 2  Next
 
Post new topic   Reply to topic    Programming Forums -> HTML forum
View previous topic :: View next topic  
Author Message
optomeb
Enthusiastic Coder


Joined: 19 May 2006
Posts: 113
Hi..im trying to do a sql query from my db to select username and how many refferals they have(i have a refferal contest going) and finally figured out the sql query..would it be hard to put that in a table ?

Reply with quote
 
Koplaf
Enthusiastic Coder


Joined: 28 May 2006
Posts: 130
Simple?
Reply with quote
 
optomeb
Enthusiastic Coder


Joined: 19 May 2006
Posts: 113
I just don't imagine how, because the table would have to be defined by how many users have refferals
And that's always changing

Reply with quote
 
Koplaf
Enthusiastic Coder


Joined: 28 May 2006
Posts: 130
<table><caption>Referrals</caption><thead><tr><th>User</th><th>Refferals</th></tr></thead><tbody><tr><td>Koplaf</td><td>9 million</td></tr>....</tbody></table>
Just loop over your result set
You can always do fancy things like pagination, etc

Reply with quote
 
optomeb
Enthusiastic Coder


Joined: 19 May 2006
Posts: 113
The way i figured i'd do it is do a for i=1 to 30 or something and display the 30 first ones..
The 30 users with most refferals, i mean
So i would do the for loop before the table, and after that include the table in the for loop ?

Reply with quote
 
montanarry
Enthusiastic Coder


Joined: 13 May 2006
Posts: 175
optomeb: you can use LIMIT in your sql query to only fetch the top 30 users
Reply with quote
 
optomeb
Enthusiastic Coder


Joined: 19 May 2006
Posts: 113
montanarry, thanks ill look that up right now
I dont even know how to explain this...i should probably ask in #php but in my user tables i dont save how many refferals each user has..only who was the refferer when you signed up
Could i select who was the refferer for each user in the database and somewhat translate that to the username...then select and display the 30 usernames that reffered the most users ?

Reply with quote
 
plantino
Enthusiastic Coder


Joined: 13 May 2006
Posts: 96
How are you storing the data? mySQL?
Reply with quote
 
WarChild
Enthusiastic Coder


Joined: 24 Feb 2006
Posts: 46
Keep close to the issue please. SQL has nothing to do with HTML. Do I have to create a new forum which will be SQL-related? Gimme a sign if this is needed.
Reply with quote
 
optomeb
Enthusiastic Coder


Joined: 19 May 2006
Posts: 113
Yes
Reply with quote
 
Page 1 of 2 Goto page 1, 2  Next
Post new topic   Reply to topic    Programming Forums -> HTML forum


Dubai Forums - Expat Help | Vegan Chat | Java Programming | Free 3D tutorials and 3d textures | Paris Forum | EU Forum
Free Dubai Classifieds | Free London Classifieds | Jobs in London

High Quality, Custom 3d animation and Web Design solutions Royal Quality Web Hosting Services Vegetarian and Animal Rights news

Powered by phpBB © 2001, 2005 phpBB Group