I know how to run an SQL query against a database based on dates, but how would I get my server to only run that query at specific times or on specific days?
I have an SQL database with activities (edit: these activities are to be displayed on a monitor as digital signage, so without any user input). Some activities run every weekday and some just on a specific day. I've put the every day activities as having the same date - 1900-01-01 - and at the moment I have an SQL Query that always displays those entries, as well as another query that only display entries from the current date:
<tbody>
<?php
require_once('../include/dbconn.php');
$result = $conn->prepare("SELECT * FROM daily WHERE Date_For='1900-01-01' ORDER BY id ASC");
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
?>
<tr>
<td><label><center><?php echo $row['Child']; ?></center></label></td>
<td><label><center><?php echo $row['Activity']; ?></center></label></td>
</tr>
<?php } ?>
<?php
require_once('../include/dbconn.php');
$result = $conn->prepare("SELECT * FROM daily WHERE DATE(Date_For) = CURDATE() ORDER BY id ASC");
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
?>
<tr>
<td><label><center><?php echo $row['Child']; ?></center></label></td>
<td><label><center><?php echo $row['Activity']; ?></center></label></td>
</tr>
<?php } ?>
</tbody>
I know I could just add the Daily Activities in with the date they're actually running on, and add a time aspect in the database, but I just wanted to check if there was a way to write one set of code to regulate access, rather than adding more work to data entry?