We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to get params from url using <a href='' ''>

Hi! This time i want id value from url, but i can't see nothing.

My href is:

<a href="/cursoscompra?idcurso=<?php echo $disp['idcurso'] ?>" id="url_compra" class="text-default"> <?php echo $disp['nombre_curso'] ?></a>

Controller:

public function indexAction() { $idcurso = $this->dispatcher->getParams('idcurso'); $curso = Cursos::findFirst(array("idcurso = :idcurso:", 'bind' => array('idcurso' => $idcurso))); $cursos=$curso->toArray(); $this->view->curso = $curso; }

And finally view CursosCompra index:

<h3 class="panel-title"><?php echo $cursos->idcurso; ?><a class="heading-elements-toggle"><i class="icon-more"></i></h3>



32.2k
Accepted
answer

You have a little mistake use $this->dispatcher->getParam('idcurso'); insteand of $this->dispatcher->getParams();

Good luck

Eagle eye!! :)

Thanks very much!