Skip to main content

Posts

Showing posts from 2017

Integrate Wordpress in Codeigniter

Step 1: Download the Wordpress framework from wordpress.org Step 2:  Copy the Wordpress folder and paste into the Codeigniter root folder Step 3: Modify the "index.php" of Codeigniter and add Wp function to Codeigniter Search this code "require_once BASEPATH.'core/CodeIgniter.php';" Then, Add the below code above this code. "require_once('[WORDPRESS FOLDER NAME]/wp-blog-header.php');" WORDPRESS FOLDER NAME = Name of the Wordpress root Folder eg: blog Step 4: Create Datebase Install Wordpress by run url "localhost/[CODEIGNITER FOLDER NAME]/[WORDPRESS FOLDER NAME]" CODEIGNITER FOLDER NAME = Name of the Codeigniter root Folder Step 5: Blog Post Fetch Query for codeigniter home page <?php ... $BlogPosts = new WP_Query('showposts=3'); if($BlogPosts->have_posts()): while($BlogPosts->have_posts()) : $BlogPosts->the_post(); the_title(); the_content(); endwhile; endif; ... ?> Source: Youtube

Cetak Rekap dengan MPDF

Controller: class Sks_rekap extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('sks/sks_rekap_model'); } public function index() {     $this->load->model('sks/sks_rekap_model');     $data['departments'] =  $this->sks_rekap_model->get_departments();     $data['center']='sks/sks_rekap_view';         /* note - you don't need to have the extension when it's a php file */     $this->load->view('dashboard/v_dashboard',$data); } public function cetak() {     $this->load->model('sks/sks_rekap_model');     $data['departments'] =  $this->sks_rekap_model->get_departments();         /* note - you don't need to have the extension when it's a php file */     $this->load->view('sks/sks_rekap_cetak_mpdf',$data); } } // model <?php //Fuile ada di model/keluar2016/keluar2016_model.php defined('BASEPATH') OR ex

FPDF dengan CodeIgniter

Cetak Surat Keputusan Controller: <?php //File in controller named surat_keputusan.php defined('BASEPATH') OR exit('No direct script access allowed'); class Cetak_surat_keputusan extends CI_Controller { public function __construct()     {         parent::__construct();         $this->load->helper('url');         $this->load->database();                $this->db->select();         $this->db->from('surat.config_sk');                $query = $this->db->get();                 return $query->result();             } public function index() {         if(isset($_GET['id_sk'])){                     date_default_timezone_set('Asia/Jakarta');                         $query=$this->load->database('surat',TRUE)->get_where('config_sk',array('id_sk'=>$_GET['id_sk']));             $data_sk=array(                 'id_sk'=>'',                 'sk_nomo

CSV into MYSQL

Create a controller as  csv.php <? php class csv extends CI_Controller { public $data ; public function __construct () { parent :: __construct (); $this -> load -> model ( 'csv_model' ); } function index () { $this -> load -> view ( 'uploadCsvView' , $data ); } function uploadData () { $this -> csv_model -> uploadData (); redirect ( 'csv' ); } } ?> And create a model as  csv_model.php <? php class csv_model extends CI_Model { function __construct () { parent :: __construct (); } function uploadData () { $count = 0 ; $fp = fopen ( $_FILES [ 'userfile' ][ 'tmp_name' ], 'r' ) or die ( "can't open file" ); while ( $csv_line = fgetcsv ( $fp , 1024 )) { $count ++; if ( $count == 1 )