Welcome Guest, Not a member yet? Register   Sign In
Passing parameter to the model..?
#1

[eluser]ChaosKnight[/eluser]
So I solved my previous newbie post for returning results from the database.. Now I have to pass a parameter id.

In my routes I configured this route:
Code:
$route['countries/:num'] = "countries/display/$id";
Because I remember from my RoR days that it's more "RESTful" to have routes display like this for a display command: /controller/:id

So I figured that the function display() will be called and the $id variable in the route will be passed as one of its parameters, so I tried this:
Code:
function display($id)
{
    $data['id'] = $id;
            
    $this->load->view('header',$data);
    $this->load->view('nav');
    $this->load->view('sidebar');
    $this->load->view('country',$data);
    $this->load->view('footer');
}

And when I tried to check that the value passed is correct before I attempt to mess around in the model, I echoed the variable $id in the view:
Code:
<?php
  echo $id;
?>

But then I found that nothing is echoed even though the parameter was supposed to carry the value of "1".
Where did I go wrong?
Thanks!
#2

[eluser]ChaosKnight[/eluser]
Sorry, I fixed it... Changed the route to:

$route['countries/(:num)'] = "countries/display/$1";




Theme © iAndrew 2016 - Forum software by © MyBB