Skip to content
  • About Us
  • Contact Us
  • Privacy Policy
  • Terms & Conditions
  • Site Map

XpertPhp

Expertphp Is The Best Tutorial For Beginners

  • Home
  • Javascript
    • Jquery
    • React JS
    • Angularjs
    • Angular
    • Nodejs
  • Codeigniter
  • Laravel
  • Contact Us
  • About Us
  • Live Demos

Home » Codeigniter » How to get last record from the mysql table in codeigniter

How To Get Last Record From The Mysql Table In Codeigniter

How to get last record from the mysql table in codeigniter

Posted on June 2, 2018July 3, 2022 By XpertPhp No Comments on How to get last record from the mysql table in codeigniter

In this tutorial, We will explain to you how to get the last record from the MySQL table in CodeIgniter. we need sometimes the last record in MySQL using CodeIgniter.

Codeigniter’s provide Active record library, its library used to we can get easily the last record in MySQL and see below example.

Read Also:
how to get last inserted id in codeigniter example

if you want to get last record from database In case you used of CodeIgniter function order_by, limit, get and row. it functions help to get a single row of the result.

See below the example of getting the last record from MySQL using CodeIgniter.

1
2
3
4
5
6
7
8
9
10
11
12
public function add()
{
    $this->load->database();
$last_record = $this->db->order_by('id',"desc")
->limit(1)
->get('users')
->row();
echo "<pre>";
print_r($last_record);
echo "</pre>";
die;
}

Please follow and like us:
error
fb-share-icon
Tweet
fb-share-icon

Recommended Posts:

  • laravel eloquent WhereIn query example
  • How To Create Line & Area Chart In Codeigniter With AmChart
  • Codeigniter 4 Morris Area & Line Charts Example
  • laravel eloquent WhereYear query example
  • how to Install Apache MySQL and PHP on Ubuntu 16.04 and 18.04
Codeigniter, MySql Tags:ci tutorial, codeigniter get last inserted record, codeigniter last record, codeigniter tutorial, CodeIgniter tutorial for beginners, get last record, last record, learn CodeIgniter

Post navigation

Previous Post: how to get last inserted id in codeigniter example
Next Post: How to Create Dynamic Xml Sitemap in Codeigniter

Latest Posts

  • Laravel Check If Foreach is Empty Example
  • Laravel Check Array Empty in Blade
  • PHP Datatables CRUD Example
  • How to Convert Date and Time from one timezone to another in php
  • how to get current date and time in php
  • Drag and Drop Reorder Items with jQuery, PHP & MySQL
  • Laravel 9 Toastr Notifications Example Tutorial
  • Laravel 9 CRUD Operation Example Using Google Firebase
  • Laravel 9 CKeditor Image Upload With Example
  • Laravel 9 Summernote Image Upload With Example

Tools

  • Compound Interest Calculator
  • Hex to RGB Color Converter
  • Pinterest Video Downloader
  • Birthday Calculator
  • Convert JSON to PHP Array Online
  • JavaScript Minifier
  • CSS Beautifier
  • CSS Minifier
  • JSON Beautifier
  • JSON Minifier

Categories

  • Ajax
  • Angular
  • Angularjs
  • Bootstrap
  • Codeigniter
  • Css
  • Htaccess
  • Javascript
  • Jquery
  • Laravel
  • MongoDB
  • MySql
  • Nodejs
  • Php
  • React JS
  • Shopify Api
  • Ubuntu

Tags

angular 10 tutorial angular 11 ci tutorial codeigniter 4 image upload Codeigniter 4 Tutorial codeigniter tutorial CodeIgniter tutorial for beginners codeigniter with mysql crud operation eloquent relationships file upload File Validation form validation Image Upload jQuery Ajax Form Handling jquery tricks jquery tutorial laravel 6 Laravel 6 Eloquent Laravel 6 Model laravel 6 relationship laravel 6 relationship eloquent Laravel 6 Routing laravel 7 Laravel 7 Eloquent laravel 7 routing laravel 7 tutorial Laravel 8 laravel 8 example laravel 8 tutorial laravel 9 example laravel 9 tutorial Laravel Framework laravel from scratch Laravel Socialite laravel social login nodejs pagination payment gateway php with mysql react js tutorial rewrite rule send mail validation wysiwyg editor

Copyright © 2018 - 2022,

All Rights Reserved Powered by XpertPhp.com