Welcome Guest, Not a member yet? Register   Sign In
capture id on click
#12

(This post was last modified: 01-04-2016, 08:48 PM by ryan.)

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()
    {
        $this->home();
    }
    
    public function home()
    {        
        $data['title'] = 'Give Me a Title';
        $data['page_header'] = 'Give me a Page Header';
        $this->load->model('model_get');
        $data['results']=$this->model_get->getMDS();
        
        $this->load->view('site_header', $data);
        $this->load->view('content_home',$data);
        $this->load->view('site_footer');
    }
    
    public function soi()
    {
        $data['title'] = 'Give Me a Title';
        $data['page_header'] = 'Give me a Page Header';
        $this->load->model('model_get');
        $data['results']=$this->model_get->getSOI(1);
        
        $this->load->view('site_header', $data);
        $this->load->view('content_soi',$data);
        $this->load->view('site_footer');
    }

view

Code:
<ul>
<?php
    foreach($results as $row)
    {
        echo '<a>'.anchor('site_controller/soi/', '<li>'.$row->name.' - '.$row->niceName.'</li>').'</a>';//I'm thinking of how to
                                                                                                                 //make this return $row
                                                                                                                 //-> ID and feed it to
                                                                                                                 //function soi
    }
?>
</ul>    

<button class='close'>Close</button>
//model
Code:
function getMDS()
{
      $query = $this->db->query("SELECT * FROM tbl_mds");
      return $query->result();
}
    
function getSOI($mds_ID)
{
      $query = $this->db->query("SELECT * FROM lnk_soi WHERE mds_ID=$mds_ID");
      return $query->result();
}

Thanks to you all for your help.
Reply


Messages In This Thread
capture id on click - by ryan - 12-31-2015, 09:34 AM
RE: capture id on click - by includebeer - 12-31-2015, 03:34 PM
RE: capture id on click - by ryan - 12-31-2015, 06:48 PM
RE: capture id on click - by includebeer - 01-01-2016, 08:58 AM
RE: capture id on click - by Wouter60 - 01-01-2016, 09:45 AM
RE: capture id on click - by ryan - 01-03-2016, 08:58 AM
RE: capture id on click - by includebeer - 01-03-2016, 10:34 AM
RE: capture id on click - by Wouter60 - 01-03-2016, 10:41 AM
RE: capture id on click - by ryan - 01-03-2016, 12:24 PM
RE: capture id on click - by PaulD - 01-03-2016, 12:53 PM
RE: capture id on click - by Wouter60 - 01-03-2016, 11:45 PM
RE: capture id on click - by ryan - 01-04-2016, 08:36 PM
RE: capture id on click - by ryan - 01-05-2016, 07:19 AM
RE: capture id on click - by mr_pablo - 01-05-2016, 08:46 AM
RE: capture id on click - by ryan - 01-05-2016, 08:53 AM
RE: capture id on click - by mr_pablo - 01-05-2016, 09:10 AM
RE: capture id on click - by ryan - 01-05-2016, 09:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB