Total Online Time

What this does?

  • add a new column in your MEMB_STAT table for total online time for the user EVER!

Does it can count in HOUR, DATE, Minutes?

  • yes

Do I need this?

  • no idea, it's your life

What can I do with this?

  • well i don't really know but i use as referral system on my test server. referral Total Online TIme = Mu CASH ^^

STEPS TO INSTALL

  1. NEED TO ADD A NEW COLUMN in MEMB_STAT TABLE

    -----IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'MEMB_STAT' AND COLUMN_NAME = 'TotalTime')
    BEGIN

     ALTER TABLE MEMB_STAT
     ADD TotalTime INT NOT NULL DEFAULT 0;

    END
    GO

    -----

  2. Change your WZ_DISCONNECT_MEMB ( stored procedure )

Code:

CREATE PROCEDURE WZ_DISCONNECT_MEMB
@memb___id varchar(10)
 AS
Begin    
set nocount on
    Declare  @find_id varchar(10)    
    Declare @ConnectStat tinyint
    Set @ConnectStat = 0     
    Set @find_id = 'NOT'
    select @find_id = S.memb___id from MEMB_STAT S INNER JOIN MEMB_INFO I ON S.memb___id = I.memb___id 
           where I.memb___id = @memb___id
    if( @find_id <> 'NOT' )    
    begin        
        update MEMB_STAT set ConnectStat = @ConnectStat, DisConnectTM = getdate(), TotalTime = TotalTime+(DATEDIFF(mi,ConnectTM,getdate()))
         where memb___id = @memb___id
            -- TIMEONLINE MOD by john_d
    end
end

GO
<table width=500>
<tr><td align=left><b>#. Name Online Hours</b></td> </tr>
<?php
$query = mssql_query("Select Top 5 memb___id,TotalTime Order By TotalTime desc");
for($i=0;$i < mssql_num_rows($query);++$i)
{
$row = mssql_fetch_row($query);
$rank = $i+1;

echo"
<tr><td align=left><b>$rank. $row[0] $row[1]</b></td> </tr>
";

}
?>
</table>


$query = mssql_query("Select Top 5 memb___id,TotalTime Order By TotalTime desc");

为了防止各别库编码不一至可把代码改为

select @find_id = S.memb___id from MEMB_STAT S INNER JOIN MEMB_INFO I ON S.memb___id = I.memb___id COLLATE DATABASE_DEFAULT
where I.memb___id = @memb___id COLLATE DATABASE_DEFAULT

相关文章

发表新评论