jmr3460 Posted September 22, 2009 Share Posted September 22, 2009 Why doesn't this work right. I have a calendar. I am trying to allow people to insert multiple day events. The single day insert worked fine so I went to work on it and as soon as I added this for loop the day I click on to add an event becomes the number of times that the for loop loops. and the number of days that I pick is the day that the event is added to. here is my loop: if ($_POST) { //start looking for multiple days here $m = $_POST["m"]; $d = $_POST["d"]; $y = $_POST["y"]; $i = $_POST['num_days']; for ($d=1; $d <= $i; $d++) { $event_date = $y."-".$m."-".$d; $insEvent_sql = "INSERT INTO calendar_events (id, event_title, event_shortdesc, event_start) VALUES('', '".$_POST["event_title"]."', '".$_POST["event_shortdesc"]."', '$event_date')"; $insEvent_res = mysqli_query($mysqli, $insEvent_sql) or die(mysqli_error($mysqli)); } } I really thought that a for loop is the way to go. Thanks for any help. Link to comment https://forums.phpfreaks.com/topic/175077-solved-problem-with-for-loop/ Share on other sites More sharing options...
jmr3460 Posted September 22, 2009 Author Share Posted September 22, 2009 Found it on this site at this link: http://www.phpfreaks.com/forums/index.php?topic=248784.0 Thanks kenrbnsn Link to comment https://forums.phpfreaks.com/topic/175077-solved-problem-with-for-loop/#findComment-922721 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.