Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7898907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:33:44+00:00 2026-06-03T08:33:44+00:00

I am working on a blogging site in codeigniter.In which the blog is to

  • 0

I am working on a blogging site in codeigniter.In which the blog is to be listed in the last one first order.ie the last one will be on top.Here in my application variable $blogs contain all the blogs to be listed and the date_created.$blogs will display the blogs,but not in the required order.Now I want to sort the blog by the date_created value.

the main model function that return the blogs is here

public function LoadAllBlogs(){

         $blogs = array();

         $this->db->select('id');
         $this->db->from('blog');
         $q=  $this->db->get();                                 

         foreach ($q->result() as $row) {
               $blog = new Blog();
               $blog->loadWithLatestPublishedEntry($row->id);
               $blogs[] = $blog;
         }

     return $blogs; //contain all the blogs entry and the date in which blog is created
}

can anyone help me…..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T08:33:46+00:00Added an answer on June 3, 2026 at 8:33 am

    You are going to need to add an ORDER BY clause to your query so they are sorted by your database. It’s pretty simple, pass the order_by() function a field name and either asc for ascending or desc for descending.

    $this->db->select('id');
    $this->db->from('blog');
    $this->db->order_by("date_created", "desc");
    $q = $this->db->get();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on migrating a textile plugin for a java blogging platform from one
Working on a page with multiple sections. at the very top there is a
Working on my first Rails project, I used Ryan Bates' Nifty-Generators to create the
I am working on a massive site for a client, but their current website
Working on rewriting the front-end of my site in Coffeescript. I understand how to
I'm developing a Web site that, amongst other things, provides blogging via Metaweblog API.
I'm trying to figure out a generic permalinks structure for blogging, in order to
Working sample using one Table SELECT t.* FROM ( SELECT TITLE.name, (TITLE.value-TITLE.msp) AS Lower,
I'm working on integrating Facebook support into a blogging engine. I registered an app
Like everybody else on this planet, I am currently working on a blogging engine

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.