By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,889 Members | 1,044 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,889 IT Pros & Developers. It's quick & easy.

Website Image

werks
100+
P: 220
Hello i'm creating a website and i want to view the Top Borrowers of Books and Number of Books Borrowed (Sample in TSDN the Top Contributor in PHP).. Does anyone know how to do this? I'm a newbie in this field..thnx..


Better Than Yesterday ^^
Feb 7 '08 #1
Share this Question
Share on Google+
4 Replies


MarkoKlacar
Expert 100+
P: 296
Hi,

You need a database in order to keep track of what books a user/customer has borrowed. Have you ever worked with MySQL?
Feb 7 '08 #2

werks
100+
P: 220
I'm using MS Access, but i have a little knowledge about MySQL
Feb 7 '08 #3

nathj
Expert 100+
P: 938
I'm using MS Access, but i have a little knowledge about MySQL
Hi,

MySQL would be better but let's press on anyway.

I assume you have a table of borrowers and some way of linking them to what they have borrowed?

When a member borrows a book you need a field against the member that indicates how many books have been borrowed. This is then incremented everytime the member borrows a book.

To display the top borrowers you run a simple peice of SQL to retreive the name and any file path to an avater they may have loaded and order the results by the borrow count and limit it to the top 10.

so assuming the table is tbl_members with ID, avatar and borrow_count as the fields we care about now:
Expand|Select|Wrap|Line Numbers
  1. select 
  2. a.ID, a.avatar, a.borrow_count
  3. from tbl_members a
  4. order by a.borrow_count desc
  5. limit 0, 10
  6.  
This will get you the top 10 borrowers. You could further restrict the results with a where clause so that only those who've borrowed more than a set number of items qualify as a top borrower to start with.

I hope this helps
nathj
Feb 7 '08 #4

werks
100+
P: 220
tnx for the logic nathj...
Feb 7 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.