这是我的代码和我的问题。当我运行 SQL 查询时,它不仅显示当前年份,而且显示前一年(2018 年),它显示(对于当前月份,我正在写这个),我认为我转换日期的方式有问题?任何帮助,将不胜感激。
<?
$fdaymonth = (new DateTime('first day of this month'))->format('m/d/Y');
$ldaymonth = (new DateTime('last day of this month'))->format('m/d/Y');
$currmonthname = Date('F');
?>
<hr />
<p class="pull-left txt-color-blueLight">Marked in system as sold in <?=$currmonthname;?>:
<?
$query = "SELECT source,count(*) as total
FROM apps
WHERE date_sold BETWEEN '" . $fdaymonth . "' and '" . $ldaymonth . "'";
$result = mysqli_query($conn,$query) or die(mysqli_error($conn));
if (mysqli_num_rows($result)== 0) echo "<strong>Error</strong>";
// Print out result
while($row = mysqli_fetch_array($result)){
echo "<b class=\"badge bg-color-greenLight\">" . $row['total'] . "</b>";
}
?>
</p>
皈依舞
慕沐林林
慕尼黑5688855
随时随地看视频慕课网APP