heey i want to make i table with following records > username,sent,ssms,points,banned and want to make ssms rest every 24 hours
rest every 24 hours
Started on the old forum in May 2011 · view the original in the archive · old links redirect here
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!!
/* I don't know everything hehe */
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
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()- 3600241;
$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()- 3600241;
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. 🙂
FREE International SMS
GYSMS.com Provides FREE International sms Reach over 775 networks in more than 221 countries at no cost to you. and the Good News is we own our SMS Hardware so there is no third party SMS API involved our services are completely Ad supported.....
Send FREE International MMS and Share Files worldwide using our MMS Service.
GTriddim Live Online Radio Station
atef wrote: 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...........
FREE International SMS
GYSMS.com Provides FREE International sms Reach over 775 networks in more than 221 countries at no cost to you. and the Good News is we own our SMS Hardware so there is no third party SMS API involved our services are completely Ad supported.....
Send FREE International MMS and Share Files worldwide using our MMS Service.
GTriddim Live Online Radio Station
i dont understand how to add it at the script, is i must add it at the index
Anthony wrote: 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.
atef wrote: 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.
atef wrote: 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...
///////////////////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
rest_ssms();
/* I don't know everything hehe */
Ponick wrote: dude , u r freaking me out...
///////////////////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
rest_ssms();
Well this he should understand, because its very simple
FREE International SMS
GYSMS.com Provides FREE International sms Reach over 775 networks in more than 221 countries at no cost to you. and the Good News is we own our SMS Hardware so there is no third party SMS API involved our services are completely Ad supported.....
Send FREE International MMS and Share Files worldwide using our MMS Service.
GTriddim Live Online Radio Station
