6 Replies Latest reply on Aug 24, 2007 6:11 AM by Günter Schenk

    How to set feature of the moment.

      Hello all,
      Hope I'm posting this in the right place.
      I am to implement a member of the month feature(or FEATURED MEMBER) which is displayed on a special page, and another page where previous members of the month (or FEATURED MEMBERS) would be displayed- That is once another member becomes the FEATURED MEMBER.

      The members would be selected from the administrative page either by a poll or at the discretion of the administrators.

      I'm a bit lost here, as to whether I have to modify the users DB to show such a feature/ any coding that I have to use so the administrator can select the member of the month at the admin control panel.

      Any help here would be deeply appreciated.
        • 1. Re: How to set feature of the moment.
          Günter Schenk Level 4
          Hi Phil,

          interesting idea !!

          The ADDT user table can of course be extended with arbitrary additional fields -- and in your case I think you should add the following fields:

          1. "featured_flag" (char 1, null) for adding a Y/N value
          2. "featured_date" (date 0000-00-00, null) for assigning the date

          now you might wonder "why a complete MySQL date, I just need the month" :: on the long run you´ll need both the "month and the "year" part of the MysQL date in order to query your data correctly -- and as it´s possible to extract these segments from from a complete MySQL date, using "date" is recommended and will of course be nicely supported by ADDT´s date input widgets or {NOW} dynamic data.

          as you might guess, the evaluation of, say, "show featured member(s) in May 2007" relies on your query -- "May" will be extractable (month "05") and "2007" as well.

          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: How to set feature of the moment.
            Level 1
            Great suggestion!
            Will experiment with it and see what happens.
            Thanks.
            • 3. Re: How to set feature of the moment.
              Level 1
              If the selection is to made by a poll though, you'd need to count the
              votes. For that, I suggest a second table with the following fields:
              id_vot, int, primary key, auto-increment
              idusr_vot, int, foreign key to the users table
              date_vot, date
              votes_vot, int, used to keep track of the votes for this user for the month.

              Then, use ADDT's Auto-Increment behavior to increment the VOTE field
              whenever a vote is cast for that user. Important to note - this table
              would never have the same user and the same date more than once. A
              userID and date combination would be unique. As votes are cast for this
              user in a particular month, the VOTES field is incremented.

              With this set up, you can still display "last month's feature", or even
              display the "top 3" if you like.

              --
              Alec
              Adobe Community Expert
              • 4. Re: How to set feature of the moment.
                Level 1
                Günter, I'm now wondering if you have any suggestions as to how best to design the adminstrative section of the site such that an admin can select a user to be displayed as the user of the month.
                I've been experimenting but haven't had much success with it.
                I want it such that a user can be selected maybe two months ahead, and once a month has been chosen, (for a particular year), no other user can be selected for that month.

                Alec, I love your suggestion too. With your suggestion, I guess the system would automatically display the user with the most votes without intervention from the site admins.
                What I don't get is that you say a userid and date combination should be unique? Can you explain further how? Because for a particular day, a user can get lots of votes and all those votes would be for the same day.

                Thanks very much for your efforts.
                • 5. Re: How to set feature of the moment.
                  Günter Schenk Level 4
                  Hi Phil,

                  >>
                  Günter, I'm now wondering if you have any suggestions as to...
                  >>

                  well, humm, nooo, your wicked scenario is admittedly *way* above my head right now -- I´d better leave it all up to Alec, as his suggestions seem far better than what I could contribute, lol :-)

                  >>
                  ...and once a month has been chosen, (for a particular year), no other user can be selected for that month
                  >>

                  with ADDT´s "check unique Key" form validation behaviour maybe ?

                  Günter Schenk
                  Adobe Community Expert, Dreamweaver
                  • 6. Re: How to set feature of the moment.
                    Level 1
                    Let me try to explain about the uniqueness...

                    You have a table of users. Here's a basic table with some sample data:
                    id_usr name_usr
                    1 bob
                    2 sue
                    3 joe
                    4 sal

                    You also have a "votes" table with 5 fields: id_vot, idusr_vot,
                    month_vot, year_vot, and votes_vot. (Notice I did not use a DATE field)

                    Now - an administrator would use a ADDT form to add the users (from the
                    USERS table) who are candidates for the employee of the month to the
                    VOTES table. This way, the admin selects a user, a month, and a year.
                    The votes defaults to zero. You can use the Check Unique ADDT server
                    behavior to make sure a certain user+month+year is unique, so a user
                    can't be added twice for a specific month/year. The initial sample data
                    may look like this:

                    id_vot idusr_vot month_vot year_vot votes_vot
                    1 2 8 2007 0
                    2 1 8 2007 0
                    3 2 9 2007 0
                    4 3 9 2007 0
                    5 4 9 2007 0

                    Sue and Bob are candidates for August. Sue, Joe, and Sal are candidates
                    for September.

                    With a different ADDT form, visitors to the site can select a candidate
                    (with a radio button) and when submitted, the Increment Field behavior
                    increments the votes_vot field. Of course, the employees displayed would
                    have to come from a SQL JOIN to get the names for the month (SELECT *
                    FROM users_usr INNER JOIN votes_vot ON users_usr.id_usr =
                    votes_vot.idusr_vot WHERE votes_vot.month_vot = ThisMonth AND
                    votes_vot.year_vot = ThisYear ORDER BY users_usr.name_usr). So, after
                    several votes in August, the table may hold the following:

                    id_vot idusr_vot month_vot year_vot votes_vot
                    1 2 8 2007 17
                    2 1 8 2007 3
                    3 2 9 2007 0
                    4 3 9 2007 0
                    5 4 9 2007 0

                    Sue has 17 votes while Bob has 3.

                    An admin can always go in the database and manually increase the votes
                    for a candidate if it is to be "by admin appointee". Also - the admin
                    can initially add a single user to the VOTES table for a specific
                    month/year - if only one user exists for a month/year, then they
                    automatically have the most votes for that month/year.

                    --
                    Alec
                    Adobe Community Expert