How can i get the end of the month or the beggining of the month to create a new table for records ? i have this code but it gets the current month...
<?php
$user = getUserData('users', 'UserUsername');
$sql = "SELECT `ticket_id`, `Uplata`, `Dobivka`, `Date` FROM `kladilnica` WHERE `Username`='$user'";
$result = $conn->query($sql);
$count = 0;
$uplata_total = 0;
if($result === false) {
echo "<b>Could not connect to database.</b>";
trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
} else {
if($result->num_rows == 0) {
echo "<b>You do not have any tickets.</b>";
} else if($result->num_rows >= 1) {
$date = date('F Y');
?>
<div class="col-md-5 col-md-pull">
<div class="panel panel-default" id="wrapper">
<table class="table table-hover">
<thead>
<tr>
<th colspan='5'><center><?= $date ?></center></th>
</tr>
<tr style="background-color: lavender;">
<th>
<td><b>Ticket ID</b></td>
<td><b>Bet</b></td>
<td><b>Gain</b></td>
<td><b>Date</b></td>
</th>
</tr>
</thead>
<?php
while($row = $result->fetch_assoc()) {
$count++;
$ticket_date = htmlentities($row["Date"]);
$ticket_id = htmlentities($row["ticket_id"]);
$uplata = htmlentities($row["Uplata"]);
$dobivka = htmlentities($row["Dobivka"]);
$uplata_total = $uplata_total + $row["Uplata"];
?>
<tbody>
<tr>
<td><?= $count ?></td>
<td><?= $ticket_id ?></td>
<td><?= $uplata ?></td>
<td><?= $dobivka ?></td>
<td><?= $ticket_date ?></td>
</tr>
<?php
}
?>
<tr style="background-color: lightgreen;">
<th colspan='4'>Total Bet: <?= $uplata_total ?></th>
<th colspan='4'>Total Win: <?= $dobivka ?></th>
</tr>
</tbody>
</table>
</div>
</div>
<?php
}
}
$conn->close();
?>