Having an issue passing info from the modal to the model so that I can do a where statement.

The first line below is the link to open the modal. Works fine no issues.

            <td><a href="javascript:;" class="openModal" data-toggle="modal" data-target="#email_details_<?php echo $SP->fit_tv_rollout_info_id;?>"> <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> </a></td> <div id="email_details_<?php echo $SP->fit_tv_rollout_info_id;?>" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <!-- dialog body --> <div class="modal-header"> <h4 class="modal-title">
          Contractor Email Details <?php echo $SP->chain;?> - <?php echo $SP->location_name;?> </h4> </div> <form class="email_details_form"> <div class="modal-body"> <?php
                        if($contractor_email_details):foreach($contractor_email_details as $CED):?> <?php echo $CED->contractor_name;?> - 
                                                                <?php echo $CED->contractor_email;?> -
                                                                <?php echo $CED->date_sent;?><br> <?php endforeach; else:?> <b><i>Sorry there is no current projects being worked on.</b></i> <?php endif;?> <div id="response"></div> </div> <!-- dialog buttons --> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </form> </div> </div> </div>

But when I open the page I can't figure out how to pass the info to model where I have my where statement

   public function contractor_email_details($data)
    {
        $rollout_id = $email_details_fit_tv_rollout_info_id;
        $this->db->select('*');
        $this->db->from('fit_tv_rollout_email');
        $this->db->where('rollout_id', $rollout_id);
        $get_query = $this->db->get();
        return $get_query->result();

I'm trying to figure out where I can get my $rollout_id from but I'm having issues and can't figure it out.

With my links they go to a different fit_tv_rollout_info_id. I can select the $SP->Chain fine that is showing correctly. But each one of these $SP->chain - $SP->location gets a unique ID. That is why I have my where statement. I have a db script that inserts when we email someone and stores it into the datbase and I want to pull the results from the database.

Any ideas?

I'm assuming you are using some sort of Javascript Ajax click event to call a url that PHP routes to this function contractor_email_details

If that's the case, and you are simply passing the ID in the url like for instance:

/url/php_page.php?id=X

Then the variable $data in the function variables is (should be) the ID. So, I would change line 3 to:

$rollout_id = $data;

See if that works for you. If not, then it could be passing something like the form object, so I would try:

$rollout_id = $data[id];

Where id is the variable name in the URL that you are using for the Ajax click event

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.