2

controller:

public function company_details()
{
    $company_name = $_GET['company_name'];  
    $this->load->model('members/Userquery');    
    $data   = array();
    $data['result'] = $this->Userquery->company_info($company_name);
    $data['navbar']='members/user/navbar';
    $this->load->view('members/user/company_info',$data);
}

view:

<html lang="eng">
    <head>
       <meta charset="UTF-8">
       <meta http-equiv="X-UA-Compatible" content="IE=edge">
       <title>Assigned Job | ATS</title>
       <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>resources/assets/bootstrap/css/bootstrap.css">
       <link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
       <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>resources/assets/fonts/font-awesome/css/font-awesome.css" rel="stylesheet">
    </head>
    <body>
       <?php $this->load->view($navbar);?>
       <?php foreach($result  as $r); { ?>
           <p><?php echo $r['company_name']; ?></p>
       <?php } ?>
    </body>
</html>

model:

public function company_info($company_name) {           
    $query=$this->db->query("SELECT  p.*,c.*,ct.* FROM post_job as p left join company as c on c.company_id=p.company_id left join citymaster as ct on ct.cityid=p.location where company_name='$company_name' ORDER BY p.job_post_id DESC"); 
    return $query->result_array();
}

In this code I want to fetch value with college_name but It show Message:

Undefined index: company_name

so how could I remove this.

Manoj Sharma
  • 1,467
  • 2
  • 13
  • 20
sam orten
  • 206
  • 3
  • 16
  • 1
    change this `where company_name='$company_name'` with where `c.company_name='$company_name'` and try. – Soni Vimalkumar Jan 04 '17 at 05:24
  • 1
    Your URL must not have `company_name`. Check if the value is there before trying to use it here `$_GET['company_name']`. – chris85 Jan 04 '17 at 05:31
  • 1
    Possible duplicate of [PHP: "Notice: Undefined variable" and "Notice: Undefined index"](http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index) – chris85 Jan 04 '17 at 05:31
  • as you are storing all fetched data to `$data['result']` but not using that !!!! – Soni Vimalkumar Jan 04 '17 at 05:31

3 Answers3

1

change this to

$query=$this->db->query("SELECT  p.*,c.*,ct.* FROM post_job as p left join company as c on c.company_id=p.company_id left join citymaster as ct on ct.cityid=p.location where company_name='$company_name' ORDER BY p.job_post_id DESC"); 

to

c.company_name='".$company_name."'
balu anand
  • 81
  • 8
0

You are iterating directly on the $result variable.

Just try this

$result = $data['result'];
Jaymin Panchal
  • 2,797
  • 2
  • 27
  • 31
0

Controller:

public function company_details()
{
    $company_name = $this->input->get('company_name');
    //echo $company_name;   //check here
    $this->load->model('members/Userquery');    
    $data   = array();
    $data['result'] = $this->Userquery->company_info($company_name);
    $data['navbar']='members/user/navbar';
    $this->load->view('members/user/company_info',$data);

}

Model :

public function company_info($company_name)
{           
$query=$this->db->query("SELECT  p.*,c.*,ct.* FROM post_job as p left join company as c on c.company_id=p.company_id left join citymaster as ct on ct.cityid=p.location where c.company_name='$company_name' ORDER BY p.job_post_id DESC"); 
return $query->result_array();
}

In view: you have to remove semicolon at the end of foreach statement. Because semicolon represents the end of loop....

<html lang="eng">
<head>
   <meta charset="UTF-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <title>Assigned Job | ATS</title>
   <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>resources/assets/bootstrap/css/bootstrap.css">
   <link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
   <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>resources/assets/fonts/font-awesome/css/font-awesome.css" rel="stylesheet">
</head>
<body>
   <?php $this->load->view($navbar);?>
   <?php foreach($result  as $r){ ?>
   <p><?php echo $r['company_name']; ?></p>
   <?php } ?>
</body>
</html>
Hikmat Sijapati
  • 6,869
  • 1
  • 9
  • 19