Welcome Guest, Not a member yet? Register   Sign In
Route in codeigniter
#1

I have this code in Routes.php
 
$routes->get('/unidades/editar/?(:id)?', 'Unidades::editar');

I have this code in the controller

public function editar($id)
    {
        $unidad = $this->unidades->where('id', $id)->first();
        $data = ['titulo' => 'Editar unidad', 'datos' => $unidad];
        echo view('header');
        echo view('unidades/editar', $data);
        echo view('footer');
    }


and the browser say when i click the botton with the $id=1

404 - File Not Found
Can't find a route for 'get: unidades/editar/1'.


Thank you for your help
Reply
#2

(09-01-2022, 09:24 PM)Estiben Wrote: $routes->get('/unidades/editar/?(:id)?', 'Unidades::editar');

What is "?(:id)?" ?

Do you want this?

PHP Code:
$routes->get('/unidades/editar/(:num)''Unidades::editar/$1'); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB