CodeIgniter Forums
String as an URL - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: String as an URL (/showthread.php?tid=22352)

Pages: 1 2


String as an URL - El Forum - 09-09-2009

[eluser]georgerobbo[/eluser]
I'm really sorry but I'm still not quite understanding how to do it.

Say my database structure is as the following.

Primary_ID Title Description Thumbnail Content
1 example learning php php.jpg we're going to learn how to use php


I then have the model stalker.php autoloaded, using the function get_article.


Code:
function get_article()
    {
        $this->db->set('slug', url_title($this->input->post('Title')));
        $this->db->set('title', $this->input->post('Title'));
        $this->db->insert('articlebase');
    }

And then I have my controller named Article.

Code:
function index($slug)
    {
        $data['title'] = 'Article';
        
        $this->db->where('stalker', $slug);
        $this->db->get();
        
        $this->load->view('meta', $data);
        $this->load->view('header');
        $this->load->view('content', $data);
        $this->load->view('index', $data);
        $this->load->view('footer');
    }