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.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Feb 2009
    Location
    Delaware
    Posts
    11
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Question Comment Engine suggestions/help

    Hola,

    I'm creating a racing-simulation based team website where I would like to have the ability for people to register and leave comments across a wide variety of page types.

    Such as:
    -- bio page (commenter can leave a note on the team members page)
    -- News Article (leave a comment on the news article in question)
    -- Vehicle setup (leave a comment under the setup and whether or not it helped, etc, etc.)

    In my mind, I can see this happening two ways...I'm just not sure which way to go about it and am looking for a little creative direction:

    1) Use a 'users' MySQL table, and create a 'comments' table for each type of comment I would like saved (bio comments, setup comments, etc) and when the user leaves a comment, it would just use predefined SQL queries to insert the data into the appropriate table.

    2) Use a 'users' table, but have only a single 'comments' table to store ALL the comments, only using different field types to filter the comments to their appropriate place.

    My problem with Option 2 is that I'm not sure how to make it so the PHP/SQL combination knows where the comments are being posted from, and how to pull them out appropriately in the end.

    That way something like:
    http://www.teamwebsite.com/setupgarage.php?id=16
    and
    http://www.teamwebsite.com/newsarticles.php?id=445

    would pull the comments specific to them from a uniform comments table. Use hidden form values?

    Or is Option 1 the best route so all the data can be hardcoded rather than based on possible hidden values?

    Suggestions / Opinions will be very helpful. Thank you!
    -- Ryan

  2. #2
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    I would go with Option 3 - your 'users' table and single 'comments' table idea. However, instead of the comments table using different 'comments' fields for the different types of comments, a single 'comments' field and an additional 'type' field to indicate the type of comment. You could then filter the comments based on 'type'.
    John

  3. #3
    New Coder
    Join Date
    Feb 2009
    Location
    Delaware
    Posts
    11
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Ok, so basically it would be something like:

    USERS
    -userID
    -userName

    COMMENTS
    -commentID
    -userID
    -type (ENUM? 'bio','news','setup',etc)
    -commentText

    And then in the actual comment SQL area, just predetermine the type via a variable in the query string?

  4. #4
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    Looks fine.

    The 'type' field can be an ENUM or you could also go with a TINYINT, and assign the comment types to values. ie:

    1 = bio
    2 = news
    3 = setup

    This would allow you to add types at any time without needing to update your db.

    And then in the actual comment SQL area, just predetermine the type via a variable in the query string?
    That would work. There may be other ways as well, depending on how your code is structured.
    John

  5. Users who have thanked PappaJohn for this post:

    PodiumAssault (03-07-2009)

  6. #5
    New Coder
    Join Date
    Feb 2009
    Location
    Delaware
    Posts
    11
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Thank you, much appreciated.

    I'll fiddle around with it some, it won't be anything super high-tech. I'll just need to protect from any sort of SQL injection.

  7. #6
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    you're welcome. good luck with it.
    John


 

Posting Permissions

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