Code: Select all
$records = array(
array('news_type_id'=>2,'content'=>'Some content'),
array('news_type_id'=>1,'content'=>'Some content'),
array('news_type_id'=>3,'content'=>'Some content'),
array('news_type_id'=>3,'content'=>'Some content'),
array('news_type_id'=>1,'content'=>'Some content'),
array('news_type_id'=>4,'content'=>'Some content'),
array('news_type_id'=>2,'content'=>'Some content')
);
Code: Select all
[u]"news_type_id" "type"[/u]
"1" "Press Releases"
"2" "Company News"
"3" "Partner News"
"4" "Published Articles"
Code: Select all
$records['Press Releases'] = array(
array('news_type_id'=>1,'content'=>'Some content'),
array('news_type_id'=>1,'content'=>'Some content')
);
$records['Company News'] = array(
array('news_type_id'=>2,'content'=>'Some content'),
array('news_type_id'=>2,'content'=>'Some content')
);
$records['Partner News'] = array(
array('news_type_id'=>3,'content'=>'Some content'),
array('news_type_id'=>3,'content'=>'Some content')
);
$records['Published Articles'] = array(
array('news_type_id'=>4,'content'=>'Some content')
);
Code: Select all
SELECT *
FROM (`news`)
Code: Select all
foreach ($records as $r){
switch($r['news_type_id']){
case 1:
$types['Press Releases'] []= $r;
break;
case 2:
$types['Focus News'] []= $r;
break;
case 3:
$types['Partner News'] []= $r;
break;
case 4:
$types['Published Articles'] []= $r;
break;
}
}
Thanks for your input.