Checking number of rows and checking status of row

Discussion in 'PHP' started by Rahul Bose, Jul 18, 2010.

  1. #1
    Hi,

    I'm currently working on a support page. Right now, it successfully allows a user to type in a question, where the information is inserted into my database. With one flaw though.

    There is a check that ensures the user doesn't have more than 3 questions at a time. I need to have this check for questions that also have a status "answered" set to 'no'.

    For example: For every question that the user asks, the answered status is set to 'no' by default. If the user has more than 3 unanswered questions at any time, they won't be able to ask another question. If they have 5 questions they have asked though perhaps, but 4 are set to 'yes', and 1 is set to 'no, they will be able to ask a question.

    What should I change to get this to work properly?
    Thanks
     
    Rahul Bose, Jul 18, 2010 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,901
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #2
    modify this line
    $checkmessage = mysql_query("SELECT message FROM `support` WHERE `message`='{$message}' and `answered` = 'no' ");
    PHP:
     
    sarahk, Jul 18, 2010 IP
  3. bencummins

    bencummins Peon

    Messages:
    55
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That wouldnt check just for that customer though, I assume the limit of 3 will be per customer rather than in total.

    I would need something like this..

    $checkmessage = mysql_query("SELECT message FROM `support` WHERE `userid`='{$userid}' AND `answered`='no'");
    
    PHP:
     
    bencummins, Jul 21, 2010 IP