SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    334
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adding Date Member Status Changed

    I have a php page where I can change the status of members in my database from 'Pending' to 'Approved', when I change a member to 'Approved' they receive an email... I want to also add a date when I change them, so once they are approved a date is added into a column in my database... If anyone can give me an idea that would be great! This is what I have so far...

    PHP Code:
    mysql_query("UPDATE `tblmembers` SET `MemberApproved`='$status' WHERE `ID`='$id'");

    //get Member Info
    $userInfo mysql_query("SELECT * FROM `tblmembers` WHERE `ID`='$id'");
    $q mysql_fetch_array($userInfo);

    //get Email info
    if ($status == "A") {
    $emailInfo mysql_query("SELECT * FROM `email` WHERE `email_id` = 'A'");

    $stat "Approved";
    }

    elseif (
    $status == "R") {
    $emailInfo mysql_query("SELECT * FROM `email` WHERE `email_id` = 'R'");

    $stat "Rejected";


  2. #2
    SitePoint Guru brent5392's Avatar
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    636
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just add the column MemberApprovedDate as a timestamp.

    Then add this to set the time
    PHP Code:
    mysql_query("UPDATE `tblmembers` SET `MemberApprovedData`= NOW() WHERE `ID`='$id'"); 
    PHP | MySQL | (X)HTML | CSS

  3. #3
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    334
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can I just add that directly under my first SQL Query?

  4. #4
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    334
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also can I add it as a DATE? I have everything set as DATE in my columns so it will just be easier, will i need to change that Query?

  5. #5
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    153 Post(s)
    Tagged
    3 Thread(s)
    you can add it into the first query....
    PHP Code:
    mysql_query("UPDATE `tblmembers` SET `MemberApproved`='$status',  `MemberApprovedData`= NOW() WHERE `ID`='$id'"); 
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  6. #6
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    153 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by tomyknoker View Post
    Also can I add it as a DATE? I have everything set as DATE in my columns so it will just be easier, will i need to change that Query?
    NOW() adds a timestamp or datestamp depending on your column definition
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  7. #7
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Create your field MemberApprovedData with the data type datetime in mysql if you are going to use NOW() function to insert the date.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  8. #8
    SitePoint Guru brent5392's Avatar
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    636
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tomyknoker View Post
    Also can I add it as a DATE? I have everything set as DATE in my columns so it will just be easier, will i need to change that Query?
    A timestamp is just another way of recording time. You can still fetch it, and format it, the same way as you can storing it with DATE.

    Also, my mistake, I seem to have made a typo in the naming of the date field. I typed 'MemberApprovedData' instead of 'MemberApprovedDate'
    PHP | MySQL | (X)HTML | CSS


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
  •