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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2010
    Location
    Earth
    Posts
    305
    Thanks
    27
    Thanked 2 Times in 2 Posts

    update not working

    I am setting up a message board and right now I am trying to set up a 'Mark as Unread" button.

    It is working to some extent, everything will change but not all at once. This is what is happening

    user1 is logged into the message board.
    They select "All" and click the "Mark as Unread" button.
    All messages that are sent by another user are changed to reflect the new status. However any message created by
    user1 is not. But if you select only the ones created by user1 and "update" they will do so.

    I have a good idea of the issue but not sure how to resolve it.

    I have 2 scenarios running at the same time

    sender vs receiver
    user2 vs user1

    sender vs receiver
    user1 vs user2


    Code:
    $clientID = user1
    PHP Code:
    if($sender == $clientID) {
      if(
    $_GET['unread_x']){
        
    $totalIDs count($my_array);
        for ( 
    $i=0$i $totalIDs$i++ ) {
          
    $query2 = ("UPDATE threads SET s_status=0 WHERE id='$my_array[$i]'");
          
    $result2 mysql_query($query2) or die(mysql_error());
        } 
    // END for
      
    }
    }
    else {
      if(
    $_GET['unread_x']){
        
    $totalIDs count($my_array);

        for ( 
    $i=0$i $totalIDs$i++ ) {
          
    $query2 = ("UPDATE threads SET r_status=0 WHERE id='$my_array[$i]'");
          
    $result2 mysql_query($query2) or die(mysql_error());
        } 
    // END for
      
    }


    When messages that have diffrent "senders" are selected it will only do 1, how do I get it to do all?

  • #2
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    What's the difference between your uses of r_status and s_status? It seems to me that this might be the problem, but without seeing more code I can only guess...
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #3
    Regular Coder
    Join Date
    Jun 2010
    Location
    Earth
    Posts
    305
    Thanks
    27
    Thanked 2 Times in 2 Posts
    I'm using the r_status & s_status to document the status of the message based on what the receiver(r) or sender(s) does.
    such as if
    r_status = 0 then either it is new or a new reply has been posted
    r_status = 1 all replies have been read
    r_status = 2 recevier has deleted the message

    I think I have my issue figured out.

    I'm send the data in an array but was not carrying that thru the whole process but doing it in the individual sections of the code

    changed my code to seems to be working

    PHP Code:
    $totalIDs count($my_array);
        for ( 
    $i=0$i $totalIDs$i++ ) {
          
    $sql2 mysql_query("SELECT sender FROM threads WHERE id='$my_array[$i]'");
          while(
    $r mysql_fetch_array($sql2)) {
            
    $sender=$r['sender'];

            if(
    $clientID==$sender) {
              if(
    $_GET['unread_x']){
                
    $query12 = ("UPDATE threads SET s_status=0 WHERE id='$my_array[$i]'");
                
    $result12 mysql_query($query12) or die(mysql_error());
              } 
    // END ($_GET['unread_x'])
            
    // END if($clientID==$sender)
            
    else {
              if(
    $_GET['unread_x']){
                
    $query12 = ("UPDATE threads SET r_status=0 WHERE id='$my_array[$i]'");
                
    $result12 mysql_query($query12) or die(mysql_error());
              } 
    // END if($_GET['unread_x'])
            



  •  

    Posting Permissions

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