I am trying to make a select of rows that are inserted into the database today.
I tried the following:
$sql2 = "SELECT * FROM `urls` WHERE 'dateurl' = CURRENT_DATE()";
$sql2 = "SELECT * FROM `urls` WHERE 'dateurl' = NOW()";
They do not seem to work. The date is stored into the database as TIMESTAMP.
Full code:
<?php
$con2 = mysqli_connect($server, $username, $password, $database);
$sql2 = "SELECT * FROM `urls` WHERE 'dateurl' = CURRENT_DATE()";
if ($result2 = mysqli_query($con2,$sql2))
{
$rowcount2 = mysqli_num_rows($result2);
if ($rowcount2 == 0) {
echo '<div class="alert alert-danger"><img src="images/check.gif"
alt="check" class="icon" /> There are no URLs shortened today.</div>';
} else {
echo '<div class="alert alert-info"><img src="images/check.gif" alt="check"
class="icon" /> Shortened today: '.$rowcount.' short URLs</div>';
}
mysqli_free_result($result2);
}
mysqli_close($con2);
?>
I always get the message: There are no URLs shortened today.
What do I do wrong? Thank you.