capture id on click |
@ryan, take notice that the anchor function already generates the <a> and </a> tags, so don't add those yourself.
This: PHP Code: echo anchor('controllerName/syllabus/'.$row->ID, 'button label'); <a href="controllerName/syllabus/x">button label</a> And as PaulID suggested, don't put the <li> tags inside the anchor, but around it, like this: PHP Code: echo '<li> . anchor('controllerName/syllabus/'.$row->ID, 'button label') . '</li>';
So I was wrong in saying this was solved. I realized it was generating page/1, page/2, page/3. I didn't realize at the time that isn't what I was looking for. It seems that I want to put the ID into the WHERE part of the sql statement. I got the controller to talk to the model but cant get the view to talk to the controller. In JS I would have the onClick function return an argument but I don't know how to do this with .anchor function. I was thinking maybe putting it in one of the attributes but that seemed dirty.
I will fix the anchor tags tomorrow at work. controller Code: public function index() view Code: <ul> Code: function getMDS() Thanks to you all for your help.
I think my explanation is still bad. Hoping this image helps.
******edit**** I just got to thinking im an idiot. I keep thinking of this as a function call to public function soi() but the function call is behind the scene. I'm thinking I need to do an onClick function call with JS or something to be able to pass the argument. PHP Code: public function soi($id) PHP Code: foreach($results as $row)
I swear I tried that .... I think I was skirting around that solution but was making my mistake at
Code: $data['results']=$this->model_get->getSOI($id); I think I was trying to create my own variable name or something like $test instead of using $ID. Thank you everyone for the help. (01-05-2016, 08:53 AM)ryan Wrote: I swear I tried that .... I think I was skirting around that solution but was making my mistake at Well, $id could be named anything you want really, but if it is an ID, why not call it ID? If you were trying to get a record via a name, you'd use $name most likely?
makes sense to me, I must have been screwing up elsewhere. I had got the id to show up in the url but it wasn't feeding to the WHERE part of SQL. All works now so I am happy.
|
Welcome Guest, Not a member yet? Register Sign In |