0

I will try to illustrate what I am trying to do :

I want my url's like :

www.mysite.com/abc-university
              /def-university
              /fde-university

Before "-university" is the name of university. All my segment(1) ends with university.

I have a class called University.In it; there is get_university() function.

In routes.php, I wrote:

$route['(:any)'] = "university/get_university";

Here is what my class looks like:

class University extends CI_Controller {

  function __construct() {
    parent::__construct();
    $this->load->model('university_model');
  }

  function get_university($university_segment){

    $query = $this->university_model->get_from_university($university_segment);

    $row = $query->row();

    echo "Welcome to " . $row->university_name . "page";                

   } 
}

$university_segment is "/abc_university.

I want to take segment-1(abc_university) into get_university($university_segment) function as parameter and fetch information from database according to that university.

I tried even _remap() function but I couldn't. Thank you...

4

1 回答 1

1
function get_university(){
$university_segment=$this->uri->segment(1);
$query = $this->university_model->get_from_university($university_segment);

$row = $query->row();

echo "Welcome to " . $row->university_name . "page";                

} 
于 2012-11-11T20:38:27.160 回答