I'd like to ask for your help. I have a CSV file in which there are values stored in 4 different categories. ( A B C D ) I have these values displayed in order by date, however, I'd like my page to display them by their category, and after that sort them by their date.
$_news_date is where the date is stored, and $news_category is where the category is stored.
For example: I'd want category A to be the first and B to be the secound, C the third, etc. Than, if I'd have 2 items as A, I'd want those to be in order by date, so the most recent would be on the top of the list. This would mean that a category A item would be above a category B item, even if it's older.
if (!count($news_headlines)>0){
echo 'Nothing to display for the moment. ';
}else{
foreach ($news_headlines as $key => $item){
list($news_id,$news_date,$news_title,$news_body,$news_category) = $item;
$formatted_date = date('d.m.y',$news_date);
if($news_category == 'A') {
$color = '#FF0000';
$weight = 'bold';
}
else if($news_category == 'B') {
$color = '#FF9900';
$weight = 'normal';
}
else if($news_category == 'C') {
$color = '#000000';
$weight = 'normal';
}
else {
$color = '#33CC33';
$weight = 'normal';
}
echo '<h2><p style="color: '.$color.'; font-weight: '.$weight.';">'.$formatted_date.' - '.$news_category.' - '.$news_title.'</p></h2>';