选择今天在db中插入的行的问题

时间:2017-12-27 14:24:07

标签: php mysql

我正在尝试选择今天插入数据库的行。

我尝试了以下内容:

$sql2 = "SELECT * FROM `urls` WHERE 'dateurl' = CURRENT_DATE()";
$sql2 = "SELECT * FROM `urls` WHERE 'dateurl' = NOW()";

它们似乎不起作用。日期作为TIMESTAMP存储在数据库中。

完整代码:

<?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);

?>

我总是收到消息:今天没有缩短网址。

我做错了什么?谢谢。

0 个答案:

没有答案