db->query($txtSQl); if ($CI->session->userdata("language") == "np") { $query = $CI->db->get_where('tbl_translations', array('english' => $text, 'nepali !=' => '')); $result = $query->row(); // Check if a translation exists in the database if ($result) { $nepaliWord = $result->nepali; echo $nepaliWord; } else { $existingQuery = $CI->db->get_where('tbl_translations', array('english' => $text)); $existingResult = $existingQuery->row(); if (!$existingResult) { $data = array( 'english' => $text, 'nepali' => '' ); $CI->db->insert('tbl_translations', $data); } echo $text; } } else { echo $text; } }