我有一个要上传到 mysql 的日历事件列表。其中一些事件每周发生,一些事件每月发生。我还希望能够在插入的每一行中插入一个特定的周数。例如
我试图做的这部分代码没有做我想做的事。屏幕上没有显示错误,也没有行插入到数据库中。
<?php
if(isset($_POST['myform'])){
$day = array("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31");
$month = array("January","February","March","April","May","June","July","August","September","October","November","December");
$year = array("2011", "2012", "2013", "2014", "2015", "2016");
$startday = $_POST['day'];
$eventplace = $_POST['eventplace'];
$eventname = $_POST['eventname'];
$eventtime = $_POST['eventtime'];
for($i=0; $i<count($year); $i++){
for($j=0; $j<count($month); $j++){
for($k=$startday; $k<count($day); $k = $k + 7){
$query = mysql_query(" INSERT INTO caldemo(day, month, year, eventname, eventtime, eventplace)
VALUES ('".$k."', '".$month[$j]."', '".$year[$i]."', '".$eventname."', '".$eventtime."', '".$eventplace."', )") ;
}
}
}
}
?>