db->query($sql); if ($qry) { $rows = $qry->result_array(); foreach($rows as $r) { $sql = "select * from t_test where T_TestSasCode like '" . $r["T_TestSasCode"] . "%' and T_TestIsActive = 'Y' and T_TestSasCode <> '" . $r["T_TestSasCode"] . "' and (T_TestIsPrice = 'Y' or T_TestIsPrintNota = 'Y')"; $qry2 = $this->db->query($sql); if ($qry2) { $rows2 = $qry2->result_array(); if (count($rows2)) { echo $r["T_TestSasCode"] . "\t\t" . $r["T_TestName"] . "\n"; } foreach($rows2 as $r2) { $price = $r2["T_TestIsPrice"]; $nota = $r2["T_TestIsPrintNota"]; echo "\t" . $r2["T_TestSasCode"] . "\t" . $r2["T_TestName"] . "\t\t" . "|$price|$nota\n"; $sql = "update t_test set T_TestIsPrice = 'N', T_TestIsPrintNota = 'N' where T_TestID = ? "; $this->db->query($sql, array($r2["T_TestID"])); } } else { print_r($this->db->error()); } } } else { print_r($this->db->error()); } } }