Welcome Guest, Not a member yet? Register   Sign In
Format url
#2

[eluser]Gavin Vickery[/eluser]
You could format the values returned from your SQL, and assign them to a new variable before you send it to the view

Code:
function index()
{
        
    $this->load->database();
    $sql = "SELECT region_id, region_name FROM regions ORDER BY region_id ASC";
    $query = $this->db->query($sql);

    $viewData['link_html'] = "";
    foreach($query->result() as $row)
    {
        $viewData['link_html'] .= '<li>';
        $viewData['link_html'] .= '<a href="/detail/'.$row->region_name.'/'.$row->region_id.'/property-in-'.$row->region_name.'.html">';
        $viewData['link_html'] .= $region->region_name;
        $viewData['link_html'] .= '</a>';
        $viewData['link_html'] .= '</li>\n';
    }
        
    $this->load->view('home', $viewData);
}

This makes your view very easy

Code:
<ul>&lt;?=$link_html?&gt;</ul>

Obviously you don't need to break out the link in the index() function that much, I just did it for clarity.

Hope that helps.


Messages In This Thread
Format url - by El Forum - 11-28-2007, 02:20 PM
Format url - by El Forum - 11-28-2007, 03:43 PM



Theme © iAndrew 2016 - Forum software by © MyBB