SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,930
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    How to show Record was "Approved"?

    My website allows registered Members to add Comments to my Articles. However, before a Comment will appear, it has to be approved by me.

    What is the best way to let my PHP code know that a Comment is ready to be displayed?

    Currently, I have a VARCHAR(20) field where I have either "Approved" or "Pending" and my queries say...
    Code:
    WHERE status='Approved';
    However, I also have a field called approved_on which is a DATETIME and allows Nulls.

    Would it be easier to lose the status field and just run my queries like this...
    Code:
    WHERE approved_on IS NOT NULL
    (or whatever the proper syntax is?!)


    Is it bad to have a field that is full of Nulls like that?


    Debbie

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,334
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by DoubleDee View Post
    What is the best way to let my PHP code know that a Comment is ready to be displayed?
    i expect you'll get a better answer in the php forum



    Quote Originally Posted by DoubleDee View Post
    Would it be easier to lose the status field
    yes



    Quote Originally Posted by DoubleDee View Post
    Is it bad to have a field that is full of Nulls like that?
    absolutely not
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,930
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    But can I lose the status field and just look in the approved_on for a DATETIME value (i.e. not null), thus signifying that the Comment was approved?

    Like this...
    Code:
    WHERE approved_on IS NOT NULL

    Debbie

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,334
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    yes

    lose the status field

  5. #5
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,930
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    yes

    lose the status field
    Okay, that is easier.

    Thanks,


    Debbie


Bookmarks

Posting Permissions

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