•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,581 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,653 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1502 | Replies: 2
![]() |
•
•
Join Date: Jan 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Okay, I'm working on a small project for my daughter's class at school. They have a fundraiser running right now and they want to post their fund raiser data on the their school website. What they want is this, they want a page listing each student and the amount that they've managed to raise so far along with a ranking.
Something like this:
Teresa H. $85 #1
Jana L. $84 #2
etc...etc...
This i've already accomplished. But they also want the ability to list the students alphabetically, which I can do also, but they each name to be clickable with a link to a page about that student containing information about their particular fundraising efforts. I guess a blog of sorts. And I have this written as well. The only thing I can't figure out is how to add each individual ranking to the individual pages.
To get the ranking above, I just select all the data from the db and use mysql_numrows($result); with a loop to get the "ranking" but I can't seem to figure this out when I have to use a select statement that requires that the userid be a match. Example:
Now how do I re-write my select statement to get my overall ranking for each student on their individual page?
Here's the basic db structure also:
uid, student_name, total_raised, homeroom
"total_raised" is the field that I'm using to get my Ranking.
Any help would be great b/c I'm stumped on this.
Something like this:
Teresa H. $85 #1
Jana L. $84 #2
etc...etc...
This i've already accomplished. But they also want the ability to list the students alphabetically, which I can do also, but they each name to be clickable with a link to a page about that student containing information about their particular fundraising efforts. I guess a blog of sorts. And I have this written as well. The only thing I can't figure out is how to add each individual ranking to the individual pages.
To get the ranking above, I just select all the data from the db and use mysql_numrows($result); with a loop to get the "ranking" but I can't seem to figure this out when I have to use a select statement that requires that the userid be a match. Example:
$query = mysql_query("SELECT * FROM students where uid =$uid")
or die(mysql_error()); Now how do I re-write my select statement to get my overall ranking for each student on their individual page?
Here's the basic db structure also:
uid, student_name, total_raised, homeroom
"total_raised" is the field that I'm using to get my Ranking.
Any help would be great b/c I'm stumped on this.
•
•
Join Date: Sep 2006
Posts: 44
Reputation:
Rep Power: 3
Solved Threads: 3
How about something like:
This should tell you how many students have total_raised greater than the student you're looking at on your individual page... which should be equal to the ranking.
It should also handles ties just fine.
select count(*) from students where total_raised > (select total_raised from students where uid=$uid)
This should tell you how many students have total_raised greater than the student you're looking at on your individual page... which should be equal to the ranking.
It should also handles ties just fine.
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- How to call a PHP function from Javascript and return the results back into Javascrip (PHP)
- PHP results in Blank Screen (PHP)
- Creating a Basic String Database (C++)
- Tutorial: Search a Database (ASP)
Other Threads in the PHP Forum
- Previous Thread: PHP and scheduled tasks
- Next Thread: Feature Posts on Index ?


Linear Mode