0
$this->db->select("*");
$this->db->from("panTab");         
$this->db->where("QCJobPanelTestId = ",$TestId);
$query = $this->db->get();
$data['get_JobPan_Data'] = $query->result();

for($i = 0; $i < sizeof($data['get_JobPan_Data']);$i++)
{
$table = "Form1";
$whereField1 = "QC1TestId";
$whereField2 = "QC1JobPanelId";
$currDiv = "form1";
$this->db->select("*");
$this->db->from($table);
$this->db->where($whereField1." = ",$TestId); 
$this->db->where($whereField2." = ",$data['get_JobPan_Data'][$i]['QCJobPanelId']); //--This value gives an error . How to access it?
$query1 = $this->db->get();
$data['getTestData'] = $query1->result();
}

Data that is coming

 Array ( 
        [get_JobPan_Data] => Array ( 
            [0] => stdClass Object( 
                [QCJobPanelId] => 293 [QCJobPanelNo] => 1 
                [QCJobPanelDesc] => Pan 1 
                [QCJobPanelJobId] => 3 
                [QCJobPanelPanelId] => 0 
                [QCJobPanelTestId] => 63 
            ) 
            [getTestData] => Array ( 
                [0] => stdClass Object ( 
                    [QC1Id] => 77 
                    [QC1JobId] => 3 
                    [QC1TestId] => 63 
                    [QCTestDesc] => 0 
                    [QC1DielectricACC_LC] => 0 
                    [QC1DielectricACC_IRA] => 0 
                    [QCRemark] => Completed 
                    [QCTestedBy] => aa 
                    [QCReviewedBy] => bb 
                    [QCWitnessedBy] => cc 
                    [QC1JobPanelId] => 293 
                    [QCTestCompletionDate] => 2016-07-29 00:00:00 
                    [QC1DateAdded] => 2016-07-29 
                ) 
           )
        ) 

Also unable to get value from $data['getTestData']:
Tried with :

  1. $data['getTestData'][0]['TestDesc']
  2. $data['getTestData'][0][0]['TestDesc']
  3. $data['getTestData']['TestDesc']
Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
VDS
  • 47
  • 8
  • what is the output of $query1. Is it an array or object. Please check that – Anish Aug 05 '16 at 04:11
  • How to check that? – VDS Aug 05 '16 at 04:12
  • `$this->db->where("QCJobPanelTestId = $TestId");` – Alive to die - Anant Aug 05 '16 at 04:24
  • 1
    try debugging `var_dump($data);` and see the format of `$data` – Asif Rahaman Aug 05 '16 at 04:31
  • Its an Array.. How to access it? – VDS Aug 05 '16 at 04:39
  • @VDS can you show that array to us? `echo "
    ";print_r($data);` do it and paste your result in your question
    – Alive to die - Anant Aug 05 '16 at 04:40
  • Array ( [get_JobPan_Data] => Array ( [0] => stdClass Object ( [QCJobPanelId] => 293 [QCJobPanelNo] => 1 [QCJobPanelDesc] => Pan 1 [QCJobPanelJobId] => 3 [QCJobPanelPanelId] => 0 [QCJobPanelTestId] => 63 ) [getTestData] => Array ( [0] => stdClass Object ( [QC1Id] => 77 [QC1JobId] => 3 [QC1TestId] => 63 [QCTestDesc] => 0 [QC1DielectricACC_LC] => 0 [QC1DielectricACC_IRA] => 0 [QCRemark] => Completed [QCTestedBy] => aa [QCReviewedBy] => bb [QCWitnessedBy] => cc [QC1JobPanelId] => 293 [QCTestCompletionDate] => 2016-07-29 00:00:00 [QC1DateAdded] => 2016-07-29 ) ) ) – VDS Aug 05 '16 at 04:52
  • 1
    then use $data['getTestData'][0]->['TestDesc'] to get data – Anish Aug 05 '16 at 04:57
  • refer the below link for more deatils. Your output is standard objec output. http://stackoverflow.com/questions/21168422/how-to-access-a-property-of-an-object-stdclass-object-member-element-of-an-arr – Anish Aug 05 '16 at 04:57
  • @Anish - It worked fine only small change required is:$data['getTestData'][0]->TestDesc... Thank you all for your help – VDS Aug 05 '16 at 06:33

2 Answers2

0

Answer to access $data including help from @Anish & @Anant :

  • $data['getTestData'][0]->TestDesc
  • ResultVariable[Array1][Array2]->Object variable

In short: - If Array, then use []
- If Object, then use ->

VDS
  • 47
  • 8
0

yes there is mistake to access object

$this->db->where($whereField2." = ",$data['get_JobPan_Data'][$i]['QCJobPanelId']);

replace it with

$this->db->where($whereField2." = ",$data['get_JobPan_Data'][$i]->QCJobPanelId);
Haresh Vidja
  • 8,340
  • 3
  • 25
  • 42