How to create auto updated/modified and created columns of a table in mysql

Your table should look like:

CREATE TABLE `new_table` (
  `id` bigint(20) NOT NULL auto_increment,  
  `modified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `created` timestamp NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`id`)

To get the modified/created column changes you need to pass null value while updating or inserting values in a table. Please see the below example to make sense

/* Insert query: */

$pdata = array(	
	'modified' => null,
	'created' => null
$val = $this->db->insert('new_table', $pdata);

/* update query:  */

$pdata = array(
	'modified' => null
$this->db->where('id', $id);
$val = $this->db->update('new_table', $pdata);


Ajax call using jQuery with response type json at CodeIgniter

Now Ajax call using jQuery is very easy and simple . Have a look the codes how easy you can manipulate your Ajax call with out Reloading your web page and get your desire results.

This code should Paste on your view page :

<script type=”text/javascript” src=””></script&gt;
<script  type=”text/javascript”>
url: “<?php echo site_url(‘login/ajaxcall’); ?>”,
type: ‘POST’,
data:{ id : 5 },
dataType: “json”,
success: function(data){
var val = “<select name=\”user\”>”+
“<option>Select from below</option>”+
error: function(data){
return false;


<button id=”buton” >Click And Get Ajax Value</button>
<p id=”ans”></p>

Now look how you can response according to the ajax request.This Code should be Paste on CodeIgniter Controller :


class Login extends CI_Controller{

public function  __construct() {

public function ajaxcall(){

$data[‘id’]   = $this->input->post(‘id’);
$data[‘name’] = ‘Ziyed’;
$data[‘age’]  = ’24’;
$data[‘sex’]  = ‘Male’;

echo json_encode($data);







CodeIgniter Pagination example using Version 2.0.2

Pagination using CodeIgniter is very easy to implement . Lets see an example with code segment .This code should be placed at Controller of CodeIgniter application folder :


class Controller_name extends CI_Controller{
 public function  __construct() {
 public function index(){
  $basurl = base_url().'index.php/product/index';
  $config['base_url'] = $basurl;
  $config['total_rows'] = $this->db->get('products')->num_rows();
  $config['per_page'] = 10;
  $config['full_tag_open'] = '<p id="pagination" style="float: right;width:20%">';

  $config['full_tag_close'] = '</p>';

  $res = $this->db->get('products', $config['per_page'], $this->uri->segment(3));
  $data['products'] = $res->result();

  $data['page'] = 'product';


At CodeIgniter View >> layout ( i used this name at controller see before ) you should just Paste this code to see pagination link:


 echo $this->pagination->create_links();


You can change outlook of pagination tag.Here is some css code:

#pagination a{
#pagination a:hover{

#pagination strong{