Codeigniter count_all for pagination


work on count_all condition.. you can use below method to find out total number of rows..


public function count_all() {
    $this->db->select ( 'COUNT(*) AS `numrows`' );
    $this->db->where ( array (
            'type' => 'Original'
    ) );
    $query = $this->db->get ( 'story_tbl' );
    return $query->row ()->numrows;
}

ou could also use the built-in num_rows() function...
$query = $this->db->where('type', 'original')->get('story_tbl');
return $query->num_rows();
Related Posts:
  • CodeIgniter models All CodeIgniter models have the same initial structure: < ?phpclass Page_model extends Model{function Page_model(){parent::Model();}}? > The first function is the code that retrieves the home page < ?phpclass P… Read More
  • Checking the values of the form-codeigniter Checking the values of the form-codeigniter We need to ensure that all of the form fields have been filled in. We can do this by simply using the empty()PHP function. Before we do this, we want to assign the value of th… Read More
  • Codeigniter Database Library The  Database librarycontains a series of helpful functions that make it easy for you to create and run queries and process the result sets from those queries. The first thing to note about the Database library in Co… Read More
  • Retrieving data-Codeigniter Retrieving POST data Toretrieve post data, you should use the function shown next. The first parameter is the name of the POST item that you are looking for.$this->input->post('some_field'); This function returns… Read More
  • Let's Make A Master Template codeigniter A simple CSS file, it ’ s time to create a generic Template view that you can reuse throughout your application. In this master template, which you can name template.php, are a series of embedded PHP calls that load certain … Read More
  • CodeIgniter system Folder The system/ folder is where all the action happens. This folder contains all the CodeIgniter code of consequence, organized into various folders: application —  The   application foldercontains the applicat… Read More
  • codeigniter routes page The  routes.php filelets you remap URI requests to specific controller functions. For example, you may have a controller named sitewith a function named index. The URI for this controller/function combination might be… Read More
  • Top codeigniter interview question and answers codeigniter interview question  What is codeigniter? Codeigniter is open source , web application framework.Its is for building websites using php.Codeigniter is loosely based on MVC pattern.Most simple framework in ph… Read More
  • codeigniter-Creating loops Creating loops in view files has been a stumbling block for a few developers. By passing a multidimensional array to a view file, you can easily establish a loop in any of your view files. Let's take a look at an example.<… Read More
  • what is CodeIgniter Helpers? Helpers, as their name implies, help you with specific tasks. Unlike libraries, helpers are not object -oriented but procedural in nature. Each helper contains one or more functions, each focusing on a specific task, with ze… Read More
  • Codeigniter count_all for pagination work on count_all condition.. you can use below method to find out total number of rows.. public function count_all() { $this->db->select ( 'COUNT(*) AS `numrows`' ); $this->db->where ( array ( … Read More
  • e-mail parameters-Codeigniter The next thing that we will need to do is to set our e-mail parameters, the sender, the recipient, any e-mail address to send a carbon copy or blind carbon copy to, the subject of our e-mail, and the message body. Take a l… Read More
  • Mysql Join query Codeigniter Mysql Join query Codeigniter code loads and initializes the database class based on your configuration settings. $query = $this->db->query('SELECT name, title, email FROM my_table'); foreach ($query->result() … Read More
  • CodeIgniter config.php The  config.php filecontains a series of configuration options all of them stored in a PHP array called, appropriately enough, $config) that CodeIgniter uses to keep track of your application ’ s  information and… Read More