• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
String as an URL

#11
[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');
    }


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.