title: how to do dynamic routing in codeigniter w/0 db
body: <p>trying to route the page as website.com/'schoolname' . if there is a controller in same name it will go through it .. else it will check whether there is such schoolname in the db if there is one it ll go to its profile page .. if there are no mattches it ll return a 404 page.</p>
  
  <p>code</p>
  
  <p>Routes</p>
  
  <pre><code> $wind =     array("app.php","assignment.php","backup.php","book.php","bulkimport.php","category.php","classes.php","conversation.php","dashboard.php","eattendance.php","event.php","exam.php","examschedule.php","exceptionpage.php","expense.php","feetypes.php","grade.php","hmember.php","holiday.php", "hostel.php","index.html" , "install.php","invoice.php" , "issue.php" ,"language.php", "lmember.php" , "mailandsms.php" ,"mailandsmstemplate.php", "mark.php" , "markpercentage.php", "media.php", "menu.php", "migration.php" ,"notice.php" , "parents.php", "paymenthistory.php" , "paymentsettings.php" , "permission.php", "profile.php", "promotion.php" , "report.php" , "reset.php", "resetpassword.php" , "routine.php" , "sattendance.php", "school.php" ,"schoolyear.php" ,"section.php", "setting.php" , "signin.php" , "signup.php" , "smssettings.php" ,"student.php" , "subject.php" , "syllabus.php" , "systemadmin.php", "tattendance.php", "teacher.php" ,"tmember.php" ,"transport.php" , "update.php" , "user.php" , "usertype.php" , "visitorinfo.php" );
  
  
  
   foreach ($wind as $win)
   {
   $controllers[] =  $win;
    }
  
     $id = $this-&gt;uri-&gt;segment(1);
  
  
     if (in_array($id.'.php', $controllers)){
  
  
     $route[$id] = $id;
  
  
    }else{
  
   $route[$id] = 'school/index/'.$id;
  
  }
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>    public function index($id = null)
  {
  
     $a = $this-&gt;systemadmin_m-&gt;get_fnall($id);
  
  
  
  
    if($a != null){
  
      $this-&gt;load-&gt;view('front/header');
       $this-&gt;load-&gt;view('front/includes');
      $this-&gt;load-&gt;view('front/sindex');
      $this-&gt;load-&gt;view('front/footer');
  
  }else{
  
  
         $this-&gt;load-&gt;view('errors/notfound');
  }
  
  
  }
  </code></pre>