get_results( "SELECT DISTINCT * FROM $tableposts WHERE post_date <= '$now' AND (post_status = 'publish') AND (date_format(post_date, '%Y%m') = '$the_month') GROUP BY $tableposts.ID ORDER BY post_date" ); uasort( $posts, "cmp" ); return $posts; } //日付昇順時間降順にソート function cmp( $a, $b ){ $a_ymd = str_replace( "-", "", substr( $a->post_date, 0, 10 ) ); $a_time = str_replace( ":", "", substr( $a->post_date, 12 ) ); $b_ymd = str_replace( "-", "", substr( $b->post_date, 0, 10 ) ); $b_time = str_replace( ":", "", substr( $b->post_date, 12 ) ); if( $a_ymd == $b_ymd ) return ( $a_time < $b_time ); else return ( $a_ymd > $b_ymd ); } ?>