<?php function myLang($text) { $text = str_replace('_', ' ', $text); $text = ucwords($text); $CI = &get_instance(); $txtSQl = "CREATE TABLE IF NOT EXISTS tbl_translations ( translation_id INT AUTO_INCREMENT PRIMARY KEY, english VARCHAR(255), nepali VARCHAR(255), created_by VARCHAR(255), created_on DATETIME DEFAULT CURRENT_TIMESTAMP, remarks TEXT, status INT DEFAULT 1 ); "; $CI->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; } }