• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
formatting query results

#5
[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
&nbsp;
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''>
          &lt;?php foreach($customers as $customer): ?&gt;
            &lt;?php for($i2=0; $i2<count($customer); $i2++) { ?&gt;
              &lt;?= "<span style='$style[$i2]'>" .$customer[$i2] .'</span><br />'?&gt;
            &lt;?php } ?&gt;
            &lt;?= br(3) ?&gt;
          &lt;?php endforeach    ?&gt;
        </p>  
        
      </div>

    </div>
&nbsp;
&nbsp;
You can see the results Here

&nbsp;
&nbsp;


Messages In This Thread
formatting query results - by El Forum - 10-13-2008, 03:15 AM
formatting query results - by El Forum - 10-13-2008, 04:05 AM
formatting query results - by El Forum - 10-13-2008, 04:09 AM
formatting query results - by El Forum - 10-13-2008, 04:16 AM
formatting query results - by El Forum - 10-13-2008, 06:44 AM
formatting query results - by El Forum - 10-13-2008, 06:55 AM
formatting query results - by El Forum - 10-13-2008, 07:24 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.