Q:

CI body class variable in view

I am looking for a way to load different body classes in my views dependent on a variable from the db.
</head>
<body class="bgcom">
<div class="strip2"></div>

I have three classes and want it loading dependent on the value returned by pt_name which in my db should be 'Engineering', 'Residential' or 'Commercial'
<?php foreach($overview->result() as $row){ ?>
    <div class="all">
        <h1><?php echo $row->pt_name ;?></h1>
    </div>
    <div class="all"><div class="rmenu">
        <a href="#" class="current"><?php echo $row->p_status ;?></a>
        <span></span>
        <!-- <a href="engineering-in-progress.html">In Progress</a> -->
    </div></div>
    <div class="all">

A:

Does this look good to you:
$bodyClass = '';
switch ( $data['pt_name'] ) {
    case 'Engineering' : $bodyClass = 'xxx'; break
    case 'Residential' : $bodyClass = 'yyy'; break
    case 'Commercial'  : $bodyClass = 'zzz'; break
}
</head>
<body class="<?php echo $bodyClass; ?>">
   <div class="strip2"></div>

