php - Group by Date - Datetime Problem -


guys, need on one.

i have list of articles using smarty want organize date,

date1 articlea date2 articleb articlec 

the problem having on date2 (or if there more 1 articles posted on same day) entire date2 shows again...i.e

date1 articlea date2 articleb articlec date2 articleb articlec 

what think problem is, date2 datetime when article posted, reason repeating each time because time values different.

i need find way remove time value datetime or somehow manipulate show date.

here code

sql

$sql = 'select ' . table_ads . ('' . '.*' . $mlang_vars . ', ') . table_ads . '.id adid, ' . table_ads_pictures . '.picture, ' . table_ads_pictures . '.`id` `picture_id`, date_format(' . table_ads . ('' . '.`date_added`,\'' . $date_format . '\') date_nice, date_format(') . table_ads . ('' . '.`date_expires`,\'' . $date_format . '\') date_expires_nice, (') . table_ads . ('' . '.date_expires < \'' . $timestamp . '\' , ') . table_ads . '.date_expires!=\'0000-00-00 00:00:00\' , ' . table_ads . '.active=0) expired, ' . table_categories . '_lang.name category, ' . table_packages . '.amount amount, ' . table_users . ('' . '.username username ' . $pri_name . ' ' . $video . ' ' . $q_vars . ' ') . table_ads . '      left join ' . table_categories . '_lang on (' . table_ads . '.category_id=' . table_categories . '_lang.id , ' . table_categories . ('' . '_lang.`lang_id` = \'' . $crt_lang . '\')       left join ') . table_packages . ' on ' . table_ads . '.package_id=' . table_packages . '.id       left join ' . table_users . ' on ' . table_ads . '.user_id=' . table_users . '.id       left join ' . table_ads_pictures . ' on ' . table_ads . '.id=' . table_ads_pictures . ('' . '.ad_id      ' . $pri_join . '      ' . $video_join . '      ' . $q_join . '      ') . $where . ' group ' . table_ads . '.id ' . $order_by . ' ' . $order_way . ' ';  

php

{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}  

you can change first line of select to

$sql = 'select ' . table_ads . ('' . '.*' . $mlang_vars . ', ') . table_ads . '.id adid, ' . table_ads_pictures . '.picture, ' . table_ads_pictures . '.`id` `picture_id`, date_format(' . table_ads . ('' . '.date(`date_added`),\'' . $date_format . '\') date_nice, date_format(') . table_ads . ('' . '.date(`date_expires`),\'' . $date_format . '\') date_expires_nice, (') . table_ads . ('' . '.date_expires < \'' . $timestamp . '\' , ') . table_ads . '.date_expires!=\'0000-00-00 00:00:00\' , ' . table_ads . '.active=0) expired, ' . table_categories . '_lang.name category, ' . table_packages . '.amount amount, ' . table_users . ('' . '.username username ' . $pri_name . ' ' . $video . ' ' . $q_vars . ' ') . table_ads . '  

basically using date() work date portion


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -