rest every 24 hours

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

    rest every 24 hours

    heey i want to make i table with following records > username,sent,ssms,points,banned
    and want to make ssms rest every 24 hours

    #2
    CREATE TABLE `records` (
    `id` int(99) NOT NULL auto_increment,
    `username` varchar(100) NOT NULL,
    `time` int(50) NOT NULL default '0',
    `sent` int(1) NOT NULL default '0',
    `ssms` int(1) NOT NULL default '0',
    `points` int(255) NOT NULL default '0',
    `banned` int(1) NOT NULL default '0',
    PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;


    try something like this..and what did mean "rest" or reset? and what the use of those field u didnt described..so u have to change data type in ur way!!
    Last edited by Ponick; 12.05.11, 20:53.
    PHP Code:
    /* I don't know everything hehe */ 
    Find me on facebook

    Comment


      #3
      i mean ssms back to 0 every 24 hours

      Added after 17 minutes:

      i want to make every user send 3 messages only everyday so im trying to create that record to reset to 0 every 24 hours
      Last edited by atef; 12.05.11, 21:40.

      Comment


        #4
        What you have to do is create a cron Job, that will run every 24 hours an update the users sms Points. that fall within the 24 hours time frame. you will need to create a php script for this purpose. However if you are not using Cpanel for your hosting

        I will Provide you with a Function that will be much easier than using the cron Job what you do is put this Function on your Login Page just after the DB Query that successfully Logs the user in.



        $lastupdate = mysql_fetch_array(mysql_query("select time from records where id='$who'"));

        $data = $lastupdate[0];

        $date_24_hours = time()- 3600*24*1;

        $currentdate = time();


        if($data<$date_24_hours)
        {
        mysql_query("UPDATE records SET points='3', time='$currentdate' WHERE id='$who'");


        }



        The First line Selects the last update time from the Table "records"

        $lastupdate = mysql_fetch_array(mysql_query("select time from records where id='$who'"));
        The Second line of code holds the variable of the data obtained from the first line

        $data = $lastupdate[0];
        The third line creates a time stamp of 24 hours

        $date_24_hours = time()- 3600*24*1;
        The fourth line this creates a time stamp of the current time this is used to update users records if their last Points update was past 24 hours.

        $currentdate = time();
        The Last line of code checks to see if the time frame obtained from the Database in the variable "$data" is older than 24 hours if it is older than 24 hours then it resets the users Point.

        if($data<$date_24_hours)
        {
        mysql_query("UPDATE records SET points='3', time='$currentdate' WHERE id='$who'");


        }

        Hope that this was much help to you and others.
        Last edited by Anthony; 13.05.11, 13:01.

        Comment


          #5
          thanks anthony but i didnt understand any thing

          Comment


            #6
            Originally posted by atef View Post
            thanks anthony but i didnt understand any thing
            Are You new to PHP because i have been very clear in my previous post even gave detailed explaination about every function of the code an how to use it. I dont think it can be any clearer than that...........

            Comment


              #7
              i dont understand how to add it at the script, is i must add it at the index

              Comment


                #8
                Originally posted by Anthony View Post
                Are You new to PHP because i have been very clear in my previous post even gave detailed explaination about every function of the code an how to use it. I dont think it can be any clearer than that...........
                It can be clear on him when you post screen shots.
                Btw I guess he want to have a copy ready and where to paste it.

                Originally posted by atef View Post
                i dont understand how to add it at the script, is i must add it at the index
                You didn't post any script.
                You can also make a new php for that.
                Did I help you?
                You can help me too
                Your donations will help me finance my studies.

                Comment


                  #9
                  Originally posted by atef View Post
                  i mean ssms back to 0 every 24 hours

                  Added after 17 minutes:

                  i want to make every user send 3 messages only everyday so im trying to create that record to reset to 0 every 24 hours
                  dude , u r freaking me out...

                  PHP Code:

                  ///////////////////lazy ezyyyyyyyyy function///////////
                  function rest_ssms()
                  {
                   
                    
                   
                  $hours_24 60*60*24;
                   
                  $currenttime time();
                   
                  $timeout $currenttime $hours_24;



                   
                  mysql_query("UPDATE records SET ssms='0' WHERE time<'".$timeout."'");







                  and add this any where in ur index script LolZ

                  PHP Code:

                  rest_ssms
                  (); 
                  PHP Code:
                  /* I don't know everything hehe */ 
                  Find me on facebook

                  Comment


                    #10
                    Originally posted by Ponick View Post
                    dude , u r freaking me out...

                    PHP Code:

                    ///////////////////lazy ezyyyyyyyyy function///////////
                    function rest_ssms()
                    {
                     
                      
                     
                    $hours_24 60*60*24;
                     
                    $currenttime time();
                     
                    $timeout $currenttime $hours_24;



                     
                    mysql_query("UPDATE records SET ssms='0' WHERE time<'".$timeout."'");







                    and add this any where in ur index script LolZ

                    PHP Code:

                    rest_ssms
                    (); 
                    Well this he should understand, because its very simple

                    Comment

                    Working...
                    X