Code To Show Total In/out Messages..

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Code To Show Total In/out Messages..

    Currently in user profiles i use this code to display total incoming /outgoing messages by that user..
    Code:
    mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE touid='".$who."'"));
    and
    Code:
    mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE byuid='".$who."'"));
    The problem i have to periodically reset the private table to reduce load on server, and doing this reset the values to zero . How can i store these values in users table so that it doesnt get reset to zero on truncating the private table and keeps getting updated with the messages received or sent too?? I hope u understand..
    I have been trying this since many days, but no success.. i think i am missing out on something small.. :sad:

    It would be great if someone helps.. I am talking about the lava script btw..

    Thanx.

    #2
    What, if your going to empty the table like you say, there wont be any messages to count therefore yu wudnt see anything. explain more clearly what you want to do
    Want something coded email me at sales@webnwaphost.com for a prices.




    Comment


      #3
      yeah thats why... i want the number of messages should be stored in the user table, and they shud be displayed in the profile from user table instead of private table...
      each time a new message or a message is being sent, both the private and user table shud be updated.. in this way the displaying of messages in profile wont reset to zero on truncating the private table...

      Comment


        #4
        i think what he means is that he would like to see the total of all users

        eg: user 1 5/10
        user 2 10/1
        user 3 6/3


        total: 21/14


        does that make sense of what you wanna do?

        Comment


          #5
          wel if he wants to do that he can do that with sligly modin the original mysql query he dosnt need to put it in ibwf users
          Want something coded email me at sales@webnwaphost.com for a prices.




          Comment


            #6
            no.. not total of all users.. Alright, forget what i said earlier..
            i want to know, what should i do, so that the total in/out messages doesnt reset to zero even on truncating the private table..
            Can they be stored in some other table too?? If yes, how?

            Comment


              #7
              yu will get 0/0 even if yu put it anywer else or itl be an incorrect result. the only thing i can think of is make a new field in users and then get a coutner started so the total sent and total recieved this would be on its own and not connected to anything else. abit same to the visit counter
              Want something coded email me at sales@webnwaphost.com for a prices.




              Comment


                #8
                Look at this code...

                Code:
                $noin = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE touid='".$uid."'"));
                $nout = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE byuid='".$uid."'"));
                
                $prin = mysql_fetch_array(mysql_query("SELECT totin FROM ibwf_users WHERE id='".$uid."'"));
                $prout = mysql_fetch_array(mysql_query("SELECT totout FROM ibwf_users WHERE id='".$uid."'"));
                
                if($noin[0]>$prin[0])
                {$diff = ($noin[0]-$prin[0])
                 $res = mysql_query("UPDATE ibwf_users SET totin='".$diff[0]."' WHERE id='".$uid."'");}
                
                if($nout[0]>$prout[0])
                { $diff = ($nout[0]-$prout[0])
                $sql = mysql_query("UPDATE ibwf_users SET totout='".$diff[0]."' WHERE id='".$uid."'");}
                I created two fields totin and totout in users table.. The rest of the code is self explanatory... But obviously its buggy.. Now if anyone could modify it, so that it works..

                thanx..

                Comment


                  #9
                  put this in ur core.php
                  Code:
                  function pm_in_out($to,$from)
                  {
                      $in_q  = mysql_fetch_array(mysql_query("SELECT totin FROM ibwf_users WHERE id='".$to."'"));
                      $in    = $in_q[0]+1;
                      $do    = mysql_query("UPDATE ibwf_users SET totin='".$in."' WHERE id='".$to."'");
                      $out_q = mysql_fetch_array(mysql_query("SELECT totout FROM ibwf_users WHERE id='".$from."'"));
                      $out   = $out_q[0]+1;
                      $do2   = mysql_query("UPDATE ibwf_users SET totout='".$out."' WHERE id='".$from."'");
                  }
                  and in ur inboxproc.php where u have
                  Code:
                    if($res)
                    {
                  
                      echo "<img src=\"images/ok.gif\" alt=\"O\"/>";
                      echo "PM was sent successfully to $whonick
                  
                  ";
                      echo parsepm($pmtext, $sid);
                      
                    }else{
                  put
                  Code:
                    if($res)
                    {
                  pm_in_out($who,$byuid);
                      echo "<img src=\"images/ok.gif\" alt=\"O\"/>";
                      echo "PM was sent successfully to $whonick
                  
                  ";
                      echo parsepm($pmtext, $sid);
                      
                    }else{

                  Comment


                    #10
                    Great!! Thanx Wizard!! Thats what i wanted!! Was trying to do it other way.. This method is easier..
                    thanx..

                    Comment

                    Working...
                    X