So I'm new to codeigniter and MVC in general. I have an app that I am converting over and I was wondering what the best way would be to handle this type of function, specifically within the view.

I have a table of categories, that looks like the table below:

```
cat_id | parent_id | catname
------------------------------
1       0           this category
2       1           that category

```

The function, given a cat\_id, spits out a formatted string complete with links. I know I shouldn't be handling the URL items until the view, so I am not sure if I rewrite this in CI how to handle the resulting array in the view.

Thoughts? Original function below:

```
    function createPath($id, $category_tbl, $except = null) {
    $s = "SELECT * FROM ".$category_tbl." WHERE cat_id = $id";
    $r = mysql_query($s);
    $row = mysql_fetch_array($r);
    if($row['parent_id'] == 0) {
        $name = $row['catname'];
        if(!empty($except) && $except == $row['cat_id']) {
            return "<a href='index.php'>Admin</a> &raquo; ".$name."";
        }
        //return "<a href='index.php'>Admin</a> &raquo; <a href='index.php?folder_id=$id'>".$name."</a> &raquo; ";
        return "<a href='category.php?catid=$id&category=".$row['slugname']."'>".$name."</a> &raquo; ";
    } else {
        if(!empty($except) && $except == $row['cat_id']) {
            $name = $row['catname'];
            return createPath($row['parent_id'],$category_tbl, false). " $name";
        } 
        $name = $row['catname'];
        return createPath($row['parent_id'],$category_tbl, false). " <a href='category.php?catid=$id&category=".$row['slugname']."'>".$name."</a> &raquo;";
    }
}

```