Welcome Guest, Not a member yet? Register   Sign In
index function with optional parameter
#1

[eluser]PermanaJ[/eluser]
I have a controller like this :

Code:
class Profile extends Controller{

    public function __construct() {
        parent::Controller();
    }

    public function index($profile_id = 0) {
        if($profile_id !== 0){
            // load profile
        }else{
            // list profile
        }
    }
}

The code above, when I open http://localhost/myapp/index.php/profile, it will list all user but when I open http://localhost/myapp/index.php/profile/23 it return 404 page not found

How can I make when visitor open http://localhost/myapp/index.php/profile, it will list all profile. But when visitor open
http://localhost/myapp/index.php/profile/23, it will show the detail of profile with Profile ID 23. Is it possible to do this without using routes ?


Messages In This Thread
index function with optional parameter - by El Forum - 04-03-2009, 08:07 PM
index function with optional parameter - by El Forum - 04-03-2009, 08:34 PM
index function with optional parameter - by El Forum - 04-04-2009, 03:44 AM
index function with optional parameter - by El Forum - 04-04-2009, 11:16 AM
index function with optional parameter - by El Forum - 04-04-2009, 06:25 PM
index function with optional parameter - by El Forum - 04-04-2009, 06:51 PM
index function with optional parameter - by El Forum - 04-04-2009, 06:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB