Codeigniter 3 – Fast setup

Download and extract codeigniter. In main folder create another folder named assets. There will be additional files for css, js and more.

Setup configuration files. Go to application/config:
– in autoload.php

$autoload['libraries'] = array('database','session');
$autoload['helper'] = array('url','form');

– in config.php

$config['base_url'] = '';
$config['index_page'] = '';
$config['encryption_key'] = 'someEncryptionKey';
$config['sess_save_path'] = sys_get_temp_dir(); //Fix problems with session

– in database.php

'username' => 'root',
'password' => 'rootPassword',
'database' => 'DatabaseName',

– in routes.php

$route['default_controller'] = 'Main_controller';

Step 2 Create Main_controller file in application/controllers
Easiest way is to copy and rename Welcome.php

Step 3 Create .htaccess file in main folder. This is a must for routing!

RewriteEngine On

RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [L,R=301]

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.php(/[^\ ]*)?\ HTTP/
RewriteRule ^index\.php(/(.*))?$$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Multilanguage CodeIgniter 3.0

In this tutorial we will implement multilanguage to CodeIgniter.

Site Default Language
Open the application/config/config.php file and specify the site’s default language.

$config['language']  = 'bulgarian';  //Language you want to be default

Language Files

The language files must be named with _lang suffix. For example, if you want to create a file containing site’s message translation then the file name might be message_lang.php.

Insert those files into the application/language/ directory with separate sub-directories for each language (for example, english, bulgarian, etc.).
Continue reading “Multilanguage CodeIgniter 3.0” »

Open window with information (AJAX WAY)

In this example we will execute AJAX that will return data which will be visualised in new window (tab).

$(document).on("click", ".sysnav", function(){ //On clicked button
	id=$(this).attr('id');                 //Command that will be executed in script.php
			var target ="/admin.php");   //Open new window
			target.NavigationPopup = data;	          //Data to be loaded in new window

Div with class “content” in new window will be filled with data from AJAX.
File “admin.php”(new window) must include this code.

var NavigationPopup;            //Data from ajax

	if(NavigationPopup){ 	$('.content').html(NavigationPopup);	} //Fill the "content" div

Load jQuery if not loaded (Asynchronous Way)

If you load scripts through ajax and they won’t execute.

After that place your code that you want to run.

Pagination example


  • «
  • $last){$top=$last;} if($x<=0){$bottom+=1;$top+=1;} } for($i=$bottom;$i<=$top;$i++){ ?>
  • ">
  • »


$(document).on("click",".pbutton",function() {
		var selected = this.text; //Selected page
		if(selected=="«"){selected = 1;} //first rows
		if(selected=="»"){selected = $(".last_page").attr("id");} //last rows
			command:"show_regular_quotation", //name of var: value of var  

The code is perfectly compatible with bootstrap.

Currency convertor with PHP

function currency_convert($amount, $from, $to){
	$result = file_get_contents("$amount&from=$from&to=$to");
	$result = explode("",$result);
	$result = explode("",$result[1]);  
	$converted_amount = preg_replace("/[^0-9\.]/", null, $result[0]);
	echo $converted_amount;