私はこのカレンダーを日曜日ではなく月曜日に始める方法を探していました。私の週カレンダーを日曜日ではなく月曜日から始める
私は$ firstDayArray ['wday'] - 1のようなさまざまなことを試してきましたが、1つ余分な空白が作成され、カレンダーは1日スキップされます。
どんな種類の助けがいいですか? P.s私は大きな騒ぎですが、練習しようとしています。私はこの偉大なサイトのほぼあらゆる場所を検索して答えを出しています。haventはそれをまだ見つけました。
<?php
define("ADAY", (60*60*24));
if ((!isset($_POST['month'])) || (!isset($_POST['year']))){
$nowArray =getdate();
$month = $nowArray['mon'];
$year = $nowArray['year'];
} else {
$month = $_POST['month'];
$year = $_POST['year'];
}
$start = mktime (12, 0, 0, $month, 1, $year);
$firstDayArray = getdate($start);
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo "Calendar:".$firstDayArray['month']."
".$firstDayArray['year']; ?>
</title>
<meta charset="utf-8">
<meta lang="da">
<link type="text/css" rel="stylesheet" href="calendar_style.css">
</head>
<body>
<form align="center" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<select name="month">
<?php
$months = Array("Januar", "Februar", "Marts", "April", "Maj", "Juni", "Juli", "August",
"September", "Oktober", "November", "December");
for ($x=1; $x <= count($months); $x++) {
echo"<option value=\"$x\"";
if ($x == $month) {
echo " selected";
}
echo ">" .$months[$x-1]."</option>";
}
?>
</select>
<select name="year">
<?php
for ($x=2016; $x<=2018; $x++) {
echo "<option";
if ($x == $year) {
echo " selected";
}
echo ">$x</option>";
}
?>
</select>
<button type="submit" name="submit" value="submit">Gå til måned</button>
</form>
<br>
<?php
$days = Array("Man", "Tir", "Ons", "Tor", "Fre", "Lør", "Søn");
echo "<table><tr>\n";
foreach ($days as $day) {
echo "<th>" .$day."</th>\n";
}
for ($count=0; $count < (6*7); $count++) {
$dayArray = getdate($start);
if (($count % 7) == 0) {
if ($dayArray['mon'] != $month) {
break;
} else {
echo "</tr><tr>\n";
}
}
if ($count < $firstDayArray['wday'] || $dayArray['mon'] != $month) {
echo "<td> </td>\n";
} else {
echo "<td>" .$dayArray['mday']."</td>\n";
$start += ADAY;
}
}
echo "</tr></table>";
?>
</body>
</html>
あなたが設定した後に ' display:block'、これらの要素を整列させるにはmargin:0 autoを設定する必要があります –