Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 7 of 7 FirstFirst ... 567
Results 91 to 92 of 92
  1. #91
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,449
    Thanks
    76
    Thanked 4,372 Times in 4,337 Posts
    I see you have an id field. Presumably that is the id of the user who filled out the bracket, yes? That is, it is a foreign key to your Users or Members table?

    So your tables should look like this:
    Code:
    CREATE TABLE members ( /* or name of your choosing */
        memberId INT PRIMARY KEY,
        memberName varchar(...),
        ...other fields describing the member...
    );
    
    CREATE TABLE teams (
        teamId INT PRIMARY KEY,
        teamName varchar(100),
        seeding INT /* optional */
    );
    
    CREATE TABLE picks (
        memberId INT REFERENCES members(memerId),
        bracketSlot varchar(10),
        int teamId REFERENCES teams(teamId) 
    );
    In other words, each pick by each person gets a *separate record*.

    And now the PHP code to insert into that table is trivial:

    You simply loop through all the fields in the POST that start with "pick" and insert them, along with the member's id and the team he/she picked, into one record in the PICKS table.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  2. Users who have thanked Old Pedant for this post:

    andrewkcohen (12-04-2011)

  3. #92
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Update

    Did anyone have a good solution to this? It looks like there were some good ideas, did anyone ever finish it?


 
Page 7 of 7 FirstFirst ... 567

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •