troubleshooting Question

How would I get this script to work with different time intervals?

Avatar of Bruce Gust
Bruce GustFlag for United States of America asked on
4 Comments4 Solutions230 ViewsLast Modified:
I'm building a calendar and I'm trying to implement the same kind of features you would find on your iphone as far as being able to schedule repeating events.

I was able to get this to work for an event that happens everyday from the starting date to the ending date:

if($_POST['frequency']=="every day")
	$the_start = strtotime($_POST['start_month'].' '.$_POST['start_day'].' '.$_POST['start_year']);
	$the_end = strtotime($_POST['end_month'].' '.$_POST['end_day'].' '.$_POST['end_year']);
	$datediff= floor($num_days/(60*60*24));
	//here's your insert code
		for ($i=0; $i<=$datediff; $i++)
		$insert = "insert into calendar (event_name, event_start, event_end, event_category, event_desc)
		values ('$event_name', '$new_event_start', '$event_end', '$event_category', '$event_desc')";
		$insertexe = mysqli_query($cxn, $insert);
			if(!$insertexe) {
			$error = mysqli_errno($cxn).': '.mysqli_error($cxn);
			} ;
		$new_event_start=date('Y-m-d H:i:s', strtotime($new_event_start) + 86400);
		//echo "$datediff dates have been added";

But I don't know how I would do this for every week, and every two weeks.

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 4 Answers and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 4 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros