Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $today = date('Y-m-d');
- $query = "SELECT lastdate FROM table_lastdate"; //I made a new table just to save the last date of the login
- $result = mysql_query($query);
- $last_date = mysql_result($result,0);
- $cur_date = strtotime($today);
- $last_date1 = strtotime($last_date);
- $difference = (($cur_date-$last_date1)/(60*60*24)); //difference in number of days
- if($difference>0){ //checks if there are any missing days to avoid duplication
- for($i=1;$i<$difference;$i++){
- $calculated_date = strtotime ("+$i day",strtotime($last_date));
- $newdate = date ('Y-m-d',$calculated_date); //creates a date which is +1 of the last_date
- mysql_query("INSERT INTO table_xyz(date,spent) VALUES('$newdate','0')");
- }
- }
- mysql_query("UPDATE table_lastdate SET lastdate = '$todays_date' WHERE lastdate = '$last_date'"); //updates the last date to todays date
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement