Php 按日期分组-日期时间问题

Php 按日期分组-日期时间问题,php,sql,smarty,Php,Sql,Smarty,伙计们,我真的需要你们的帮助 我有一个使用smarty的文章列表,我想按日期组织 Date1 ArticleA Date2 ArticleB ArticleC 我遇到的问题是,在Date2上(或者如果在同一天发布了超过1篇文章),整个Date2会再次出现…即 Date1 ArticleA Date2 ArticleB ArticleC Date2 ArticleB ArticleC 我认为问题在于,Date2是文章发布时的datetime,因此每次重复它的原因是因为时间值不同 我需要找到一种

伙计们,我真的需要你们的帮助

我有一个使用smarty的文章列表,我想按日期组织

Date1
ArticleA
Date2
ArticleB
ArticleC
我遇到的问题是,在Date2上(或者如果在同一天发布了超过1篇文章),整个Date2会再次出现…即

Date1
ArticleA
Date2
ArticleB
ArticleC
Date2
ArticleB
ArticleC
我认为问题在于,Date2是文章发布时的datetime,因此每次重复它的原因是因为时间值不同

我需要找到一种方法从datetime中删除时间值,或者以某种方式操纵它以仅显示日期

这是我的密码

SQL


您可以将select的第一行更改为

$sql = 'select ' . TABLE_ADS . ('' . '.*' . $mlang_vars . ', ') . TABLE_ADS . '.id as adid, ' . TABLE_ADS_PICTURES . '.picture, ' . TABLE_ADS_PICTURES . '.`id` as `picture_id`, date_format(' . TABLE_ADS . ('' . '.DATE(`date_added`),\'' . $date_format . '\') as date_nice, date_format(') . TABLE_ADS . ('' . '.DATE(`date_expires`),\'' . $date_format . '\') as date_expires_nice, (') . TABLE_ADS . ('' . '.date_expires < \'' . $timestamp . '\' and ') . TABLE_ADS . '.date_expires!=\'0000-00-00 00:00:00\' and ' . TABLE_ADS . '.active=0) as expired, ' . TABLE_CATEGORIES . '_lang.name as category, ' . TABLE_PACKAGES . '.amount as amount, ' . TABLE_USERS . ('' . '.username as username ' . $pri_name . ' ' . $video . ' ' . $q_vars . ' from ') . TABLE_ADS . ' 
$sql='select'。表2.广告。(“.......”$mlang_vars.,”)。表"广告"。id为adid'。表格(广告)(图片)。图片'。表格(广告)(图片)`id`as`picture\\u id`,date\\u格式('.TABLE\\u ADS.('.'..date(`date\\u added`.),\'.$date\\u格式.'.\'')as date\\u nice,date\\u格式('.'date\\u expires'),\'.$date format.\'''.''.$date ADS.('.'.'date expires<\.$timestamp.'.'.'.'.'')as日期到期('.$timestamp.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.TABLE_ADS.'.date_expires!\'0000-00-00 00:00:00\'和'.TABLE_ADS.'.active=0)已过期'。表2“类别”_lang.name作为类别'。表(u)。以“金额”表示的金额。表2.1用户。('.'..username作为用户名'.$pri_name.'.$video.'.$q_vars.'from')。表1“广告”
基本上只使用日期部分

{foreach from=$listings_array name="date_nice" item=k}{$k.date_nice} 
{foreach from=$listings_array  name="listing" item=v} 
   {if $k.date_nice==$v.date_nice} 
        {include file="short_listing.html"} 
   {/if} 
{/foreach} 
{/foreach} 
$sql = 'select ' . TABLE_ADS . ('' . '.*' . $mlang_vars . ', ') . TABLE_ADS . '.id as adid, ' . TABLE_ADS_PICTURES . '.picture, ' . TABLE_ADS_PICTURES . '.`id` as `picture_id`, date_format(' . TABLE_ADS . ('' . '.DATE(`date_added`),\'' . $date_format . '\') as date_nice, date_format(') . TABLE_ADS . ('' . '.DATE(`date_expires`),\'' . $date_format . '\') as date_expires_nice, (') . TABLE_ADS . ('' . '.date_expires < \'' . $timestamp . '\' and ') . TABLE_ADS . '.date_expires!=\'0000-00-00 00:00:00\' and ' . TABLE_ADS . '.active=0) as expired, ' . TABLE_CATEGORIES . '_lang.name as category, ' . TABLE_PACKAGES . '.amount as amount, ' . TABLE_USERS . ('' . '.username as username ' . $pri_name . ' ' . $video . ' ' . $q_vars . ' from ') . TABLE_ADS . '