How to retrieve only 1 URL value with CodeIgniter?

2

I'm passing two parameters link

 public function votar($id) {
    echo $id;
    die;
 }

And it returns me 4-slug-of-something. I just wanted to retrieve the ID but displaying the two parameters in the url, how do I do that?

My route looks like this:

$route['votar/(:any)'] = 'Home/votar/$1';

Vote button

<a href="<?= base_url("votar/{$row->id}-{$row->slug}"); ?>" class="btn btn-vote">VOTAR</a>
    
asked by anonymous 24.01.2017 / 14:49

1 answer

2

The parameter delimitation is the /

You need to mount the link like this:

<a href="<?= base_url("votar/{$row->id}/{$row->slug}"); ?>" class="btn btn-vote">VOTAR</a>

Change the - dash by the /

It looks like this: link

If you want to keep it the other way, you will get everything together, so you have to slice the string.

    
24.01.2017 / 14:53