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

  • Home
  • SEARCH
  • 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 8922911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:58:02+00:00 2026-06-15T06:58:02+00:00

i am outputting database entries with the following code: <div id=main_area> <div id=container> <div

  • 0

i am outputting database entries with the following code:

<div id="main_area">
<div  id="container">
<div id="php_container" role="main">
<?php
include('connect_it.php');
$sqlget= "SELECT * FROM dbtablename";
$sqldata= mysqli_query ($dbcon,$sqlget) or die('this is an error');
while ($row = mysqli_fetch_array($sqldata, MYSQLI_ASSOC)) {
echo $row[ 'li' ] ;
}
?>
</div>
</div>
</div>

on page load, i’d like the database entries to be ordered by their date (from most recent to least recent) which is stored in a mysql field called ‘added’ in the format DD/MM/YY.

i’m not sure if it can be done, but as another option, the date is within a span defined by <span id="date">date: 27/11/11</span> so perhaps this span could be used to order the data?

so my question is, how can i make the initial output ordered by date from most recent to least recent?

i have tried:

$sqlget= "SELECT * FROM dbtablename ORDER BY added ASC";

but i got unexpected results.

thank you.

  • 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-15T06:58:04+00:00Added an answer on June 15, 2026 at 6:58 am

    If your added column is a DATE, DATETIME or TIMESTAMP type you can use DATE_FORMAT like so,

    $sqlget= "SELECT *, DATE_FORMAT(added,'%d/%m/%y') as addedFormated FROM dbtablename ORDER BY added ASC";
    

    See, https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format

    Otherwise if it is a string try (it really should be a DATE type though),

    $sqlget= "SELECT *, STR_TO_DATE(added,'%d/%m/%y') as addedFormated FROM dbtablename ORDER BY STR_TO_DATE(added,'%d/%m/%y') ASC";
    

    https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_str-to-date

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My code is retrieving player names from a database and outputting them into a
Possible Duplicate: outputting values from database into html table PHP I am trying to
I have a Ci script outputting database values. On these values '#commentLink' and '#commentBox'
I am updating my database with a form. I have it outputting the values
i am outputting json data from a php file (example of my output) {news:[{title:title
Why the two printf statements are outputting different values? int main() { int n=10;
I'm using a PHP array that is gathering data from a mysql database. I'm
I have just started building android application. I have a php script outputting a
i got a little problem with searching my database and outputting the data. This
I'm outputting values from a database (it isn't really open to public entry, but

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.