Welcome Guest, Not a member yet? Register   Sign In
How to pass parameter in a dynamic link from a view in codeIgniter
#1

I am facing an issue with my system. I have recently designed a system in CodeIgniter. In my system, I want to pass a dynamic parameter in a dynamic link from a view. but I don't know how to pass it. I have passed the dynamin parameter from one controller to another controller with the base URL like [b]redirect(base_url().$pr.'/'.'home/index');[/b] where $pr stores the dynamic value of the parameter. for this, I have also defined a route like this [b]$route['(:any)/home/index'] = 'home/index';[/b] After doing the all the above stuff the URL looks like [b]localhost/niyog/sad/home/index[/b] where sad is the parameter, home is the controller and index is the method. Now I want to do the same thing from view in the dynamic link.

Code:
<h4 class="title"><a href="<?php echo base_url($links['link']); ?>" target="_blank" ><?php echo $links['link_name']; ?></a></h4>
[font=Arial,]and[/font]

Code:
<a href="<?php echo base_url('home/new_registration'); ?>" class="btn btn-info" role="button">Proceed</a>
[font=Arial,][font=Arial,]I want to make the first dynamic link looks like [font=Arial,][b]localhost/niyog/sad/cand_info/load_cand_info[/b] and also the second one looks like [b]localhost/niyog/sad/home/new_registration[/b][/font]

so how can I do that....can anyone help me????
[b]view.php[/b][/font]
[/font]


Code:
</header>

    <div class="row about-container">

      <div class="col-lg-6 content order-lg-1 order-2">
    <?php foreach($list as $links){ ?> 
    <?php if($links['sl']==1){
    if(strtotime(date('d-m-Y H:i:s'))>=strtotime($links['enable_date']) && strtotime(date('d-m-Y H:i:s'))<=strtotime($links['stop_date']) || $links['enable_date']=='' && $links['stop_date']=='')
    {
    ?>
        <div class="icon-box wow fadeInUp">
          <div class="icon"><i class="<?php echo $links['link_icon']; ?>"></i></div>
          <h4 class="title"><a href="<?php echo base_url($links['link']); ?>" target="_blank" ><?php echo $links['link_name']; ?></a></h4>
          <p class="description"><?php echo $links['link_desc']; ?></p>
        </div>
        <?php
        }
        }
        else{
            if(strtotime(date('d-m-Y H:i:s'))>=strtotime($links['enable_date']) && strtotime(date('d-m-Y H:i:s'))<=strtotime($links['stop_date']) ||$links['enable_date']=='' && $links['stop_date']=='')
    {
        ?>
         <div class="icon-box wow fadeInUp" data-wow-delay="0.2s">
          <div class="icon"><i class="<?php echo $links['link_icon']; ?>"></i></div>
          <h4 class="title"><a href="<?php echo base_url($links['link']); ?>"><?php echo $links['link_name']; ?></a></h4>
          <p class="description"><?php echo $links['link_desc']; ?></p>
        </div>
    <?php
    }
    }
           } ?>

      </div>

      <div class="col-lg-6 background order-lg-2 order-1 wow fadeInUp">
        <img src="<?php echo base_url('assets/img/how-to-apply.jpg'); ?>" class="img-responsive" alt="" height="500" width="500">
      </div>
    </div>
[font=Arial,][font=Arial,][b][b][font=Arial,][b]other_view.php[/b][/b][/font][/b][/font][/font]

Code:
<li class="col-xs-12 list-group-item" style="text-align:right">
            <a href="<?php echo base_url('home/index'); ?>" class="btn btn-info" role="button">Go Back</a>
            <a href="<?php echo base_url('home/new_registration'); ?>" class="btn btn-info" role="button">Proceed</a>
        </li>
[font=Arial,][font=Arial,][b][b][font=Arial,][b][b][font=Arial,][b]user.php[/b][/b][/font][/b][/b][/font][/b][/font][/font]

Code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class User extends CI_Controller {
public function __construct() {
    parent::__construct();
    $this->load->helper('url_helper');
    $this->load->helper('form');
    $this->load->helper('file');
    $this->load->helper('captcha');
$this->load->model('user_model');
    $this->load->library('session');

}
public function index($var = null) {
        $pr = $this->uri->segment(1);

        if ($pr == '') {
            $result['data'] = $this->user_model->display_recruitment();
            $this->load->view('templates/rec_header');
            $this->load->view('user_view', $result);
            $this->load->view('templates/rec_footer');
} else {
redirect(base_url().$pr.'/'.'home/index');




                }

            }

        }

?>
Reply


Messages In This Thread
How to pass parameter in a dynamic link from a view in codeIgniter - by rkb2020 - 04-14-2020, 10:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB