0
Good morning, I have a code "ready" in which the user must register an event that will later be shown in a calendar, well the first part is already ready but the second is giving me problems, I would like to do a check of the initial and final date and insert a text (Ex: event!!) in the days between these dates,PS: the dates are purchased via database, all data are already recorded
example: start date 6/6/16 end date 16/6/16 , the text should appear on all days from 6 to 16
<?php
include 'connect.php';
$sql = "select Data_inicio, Data_fim from walldata";
$result = mysqli_query($con, $sql);
if ($result->num_rows > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$Data_in = $row['Data_inicio'];
$Data_fim = $row['Data_fim'];
}
}
if (isset($_POST['datac'])) {
$datee = explode('-', $_POST['datac']);
$mes = $datee[1];
$ano = $datee[0];
$ultimo_dia = date("t", mktime(0, 0, 0, $mes, '01', $ano));
} else {
$mes = date('m');
$ano = date('o');
}
if ($mes == date('m')) {
$ultimo_dia = date("t", mktime(0, 0, 0, $mes, '01', $ano));
$dias = $ultimo_dia;
} elseif ($mes == '') {
$mes = date('m');
$ano = date('o');
$dias = $ultimo_dia;
} else {
$dias = $ultimo_dia;
}
?>
<form method="post" action="date.php">
<input type="month" name="datac" value="<?php echo $ano ?>-<?php echo $mes ?>" required><input type="submit">
<table class="table table-striped" width="210" border="2" cellspacing="4" cellpadding="4">
<tr>
<td width="80px"><center>Domingo</center></td>
<td width="80px"><center>Segunda</center></td>
<td width="80px" class="center">Terça</td>
<td width="80px" class="center">Quarta</td>
<td width="80px" class="center">Quinta</td>
<td width="80px" class="center">Sexta</td>
<td width="80px" class="center">Sábado</td>
</tr>
<?php
echo "<tr>";
for ($i = 1; $i <= $dias; $i++) {
$diadasemana = date("w", mktime(0, 0, 0, $mes, $i, $ano));
$cont = 0;
if ($i == 1) {
while ($cont < $diadasemana) {
echo "<td></td>";
$cont++;
}
}
echo "<td width='100px' height='100px'><center>";
echo $i;
echo "</center></td>";
if ($diadasemana == 6) {
echo "</tr>";
echo "<tr>";
}
}
echo "</tr>";
?>
</table>
</form>
</body>
</html>
I need you to be more specific. Where do you want to put the word ? Type, on each date ?
– LucaoA
Yes on the days when the event happens
– Nikk 17016
example, start date 6/6/16 end date 16/6/16 , the text should appear on all days from 6 to 16
– Nikk 17016