I am trying to make a query in which you show me an article in this library using the uri library
In the index I show a list of courses, if I click on a course through the recovered id I want to show only that course individually.
shows me all the courses but does not show me the individual.
As you can see, the url does change with respect to the id retrieved from the query. this is my controller
function index(){
$data['segmento'] = $this->uri->segment(3);
$this->load->view('codigoFacilito/headers');
if(!$data['segmento']){
$data['cursos'] = $this->codigofacilito_model->obtenerCursos();
}
else{
$data['cursos'] = $this->codigofacilito_model->obtenerCurso($data['segmento']);
}
$this->load->view('cursos/cursos', $data);
}
This is my model
function obtenerCurso($id){
$this->db->where('idCurso', $id);
$query = $this->db->get('cursos');
if($query->num_rows()>0){
return $query;
}
else{
return false;
}
}
This is my view
<?php
if($cursos){
foreach ($cursos->result() as $curso) {
?>
<ul>
<li><a href="<?= $curso->idCurso ?>"><?= $curso->nombreCurso ?></a></li>
</ul>
<?php
}
}
else{
echo "<p>Error en la aplicación</p>";
}
?>
</body>
</html>
greetings and thanks for your help