Извините, если вопросы кажутся глупыми, но я создал массив в своем контроллере, и я передаю его в представление с массивом $ data ['sample'].
Вот мой запрос MYSQL:
SELECT workplace.id, workplace.type,
MAX(IF(workplace.region_id = 1, workplace.name,0)) 'Dhaka South',
MAX(IF(workplace.region_id = 2, workplace.name,0)) 'Dhaka North',
MAX(IF(workplace.region_id = 3, workplace.name,0)) 'Savar',
MAX(IF(workplace.region_id = 4, workplace.name,0)) 'Narayangonjh',
MAX(IF(workplace.region_id = 5, workplace.name,0)) 'Mymensingh',
MAX(IF(workplace.region_id = 6, workplace.name,0)) 'Barisal',
MAX(IF(workplace.region_id = 7, workplace.name,0)) 'Faridpur',
MAX(IF(workplace.region_id = 8, workplace.name,0)) 'Jessore'
FROM workplace
WHERE workplace.type='area'
GROUP BY workplace.id
Если f print_r для образца, то он выглядит как
SELECT workplace.id, workplace.type, MAX(IF(workplace.region_id = 1, workplace.name,0)) 'Dhaka South', MAX(IF(workplace.region_id = 2, workplace.name,0)) 'Dhaka North', MAX(IF(workplace.region_id = 3, workplace.name,0)) 'Savar', MAX(IF(workplace.region_id = 4, workplace.name,0)) 'Narayangonjh', WHERE workplace.type='area' GROUP BY workplace.id
Array ([0] => stdClass Object ([id] => 15 [type] => area [Дакка Юг] => Джатрабари [Дакка Север] => 0 [Савар] => 0 [Нараянгондж] => 0 [Мименсингх] => 0 [Барисал] => 0 [Фаридпур] => 0 [Джессор] => 0)
[1] => stdClass Object
(
[id] => 16
[type] => area
[Dhaka South] => Lalbag
[Dhaka North] => 0
[Savar] => 0
[Narayangonjh] => 0
[Mymensingh] => 0
[Barisal] => 0
[Faridpur] => 0
[Jessore] => 0
)
[2] => stdClass Object
(
[id] => 17
[type] => area
[Dhaka South] => Dhanmondi
[Dhaka North] => 0
[Savar] => 0
[Narayangonjh] => 0
[Mymensingh] => 0
[Barisal] => 0
[Faridpur] => 0
[Jessore] => 0
)
[3] => stdClass Object
(
[id] => 18
[type] => area
[Dhaka South] => 0
[Dhaka North] => Gulshan
[Savar] => 0
[Narayangonjh] => 0
[Mymensingh] => 0
[Barisal] => 0
[Faridpur] => 0
[Jessore] => 0
)
Я хочу использовать эти данные в таблице данных, в которой в качестве заголовка будет указан идентификатор, тип, Дакка Юг, Дакка Север, Савар, Нараянгондж, Мименсингх, Барисал, Фаридпур, Джессор.значения в tbody как значения. Пожалуйста, помогите, если можете.