[eluser]John_Betong[/eluser]
Hi Gafro,
Try this:
Controller:
Code:
//========================================================
function index($data=array()) {
for($i2=0; $i2<10; $i2++) {
$data['customers'][] = array(
'Name',
'Title: 1',
'Title: 2',
'Title: 3',
'email',
'address: 1',
'address: 2',
'address: 3',
'address: 4',
'City:',
'Country:',
'Zip code',
'Tel:',
'Fax:',
'Source:'
);
}//endforeach
$total_fields = count($data['customers'][0]);
for($i2=0; $i2<$total_fields; $i2++) {
switch($i2) {
case 0: $style="font-size:14px; font-weight:bold"; break; // Name
case 1:
case 2:
case 3: $style="font-size:12px; color:#00f'"; break; // Title
case 4: $style="font-size:16px; color:#f00"; break; // Email
case 5:
case 6:
case 7:
case 8: $style="font-size:14px; color:#060"; break; // Tel
case 9:
case 10: $style="font-size:16px; color:#00f"; break; // City, Country
case 11: $style="font-size:18px; color:#060"; break; // Zip code
case 12:
case 13: $style="font-size:12px; color:#009"; break; // Tel, Fax
case 14: $style="font-size:22px; color:#009"; break; // Source
break; echo 'Should never get here';
}//endswitch
$data['style'][$i2] = $style;
}//endfornext loop
if (FALSE) {
echo '<pre>';
print_r($data);
echo '</pre>';
}
// }//endfornext14:44 10/10/2008;
// die;
$data['footer'] = $this->load->view('_footer', $data, TRUE);
$output = $this->load->view('_ci_forums_viewthread_93697', $data, TRUE);
echo $output;
}//endfunc
View:
Code:
<div style='width:500px; margin:1em auto 14em; scroll:auto; border:solid 1px #ddd; text-align:left'>
<div style='float:left; width:60%; margin:1em auto 0 1em; border:solid 1px #bbb'>
<p style='width:90%; margin:2em auto''>
<?php foreach($customers as $customer): ?>
<?php for($i2=0; $i2<count($customer); $i2++) { ?>
<?= "<span style='$style[$i2]'>" .$customer[$i2] .'</span><br />'?>
<?php } ?>
<?= br(3) ?>
<?php endforeach ?>
</p>
</div>
</div>
You can see the results
Here