Website Image

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • werks
    New Member
    • Dec 2007
    • 218

    Website Image

    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 ^^
  • MarkoKlacar
    Recognized Expert Contributor
    • Aug 2007
    • 296

    #2
    Hi,

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

    Comment

    • werks
      New Member
      • Dec 2007
      • 218

      #3
      I'm using MS Access, but i have a little knowledge about MySQL

      Comment

      • nathj
        Recognized Expert Contributor
        • May 2007
        • 937

        #4
        Originally posted by werks
        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:
        Code:
        select 
        a.ID, a.avatar, a.borrow_count
        from tbl_members a
        order by a.borrow_count desc
        limit 0, 10
        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

        Comment

        • werks
          New Member
          • Dec 2007
          • 218

          #5
          tnx for the logic nathj...

          Comment

          Working...