Codeigniter - in the view or in the controller?
These 0, 4 and 7 means nothing to any code reader, nor 1, 2 and 3 for the label.

Move this logic in the controller and consider using ENUMs in your controller class i.e.:

const BADGE_IMPORTANT = 0;
const BADGE_INFO = 4;
const BADGE_WARNING = 7;


This way it will be more readable for the one who will read and change it later, also it will became less hard changable and more reusable.

Also, try to not echo HTML, I mean, use PHP blocks only when you have PHP in it. HTML should be outside:

&lt;?php foreach ($solicitud as $key =&gt; $value): ?&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;span class="label label-sm&lt;?=$label;?&gt;"&gt;&lt;?=ucfirst($value['status']);?&gt;&lt;/span&gt;&lt;/td&gt;
              &lt;td&gt;&lt;span class="badge &lt;?=$class;?&gt;"&gt;&lt;?=$value['priority'];?&gt;&lt;/span&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?=$value['sname'].$value['last_name'];?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?=$value['name'];?&gt;&lt;/td&gt;
               ....
          &lt;/tr&gt;
&lt;?php endforeach; ?&gt;