выполнить запрос в цикле, а не в конце
$startDate='2011-08-10';
$endDate='2011-10-23';
for ($i = strtotime($startDate); $i <= strtotime($endDate); $i = strtotime('+1 day', $i)) {
if (date('N', $i) == 1){
$query = "INSERT INTO class(Day, Date) VALUES('Monday','".date('Y-m-d', $i)."')";
mysql_query($query); // you execute the query here otherwise it will overwrite over and over and only the last query will be executed
}
}
или навалом
$startDate='2011-08-10';
$endDate='2011-10-23';
$query = "INSERT INTO class(Day, Date) VALUES ";
for ($i = strtotime($startDate); $i <= strtotime($endDate); $i = strtotime('+1 day', $i)) {
if (date('N', $i) == 1){
$query .= "('Monday','".date('Y-m-d', $i)."'),";
}
}
$query = substr($query, 0, -1).";"; // remove the last "," and add ;
mysql_query($query);