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 8013613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:40:39+00:00 2026-06-04T19:40:39+00:00

I am pulling records out of my mysql database using php and want to

  • 0

I am pulling records out of my mysql database using php and want to order them by a database field called expdate.

The dates for the reminders are stored in the table in this format 17-04-12 as varchar.

I am using the following code to pull all the records out and order them by the expdate column.

    <table border="0" style="text-align:left;">
      <tr style="text-align:left;">
        <th style="text-align:left;" width="200px"  scope="col">Name</th>
        <th style="text-align:left;" width="200px"  scope="col">Email</th>
      <th style="text-align:left;" width="200px" scope="col">Telephone</th>
      <th style="text-align:left;" width="200px" scope="col">Current Cover Expires</th>
      </tr>
    <?php
    $today = date("d-m-y");
    $result = mysql_query("SELECT * FROM ymeg_chronoforms_data_NewsletterSubscribe ORDER BY expdate")or die(mysql_error());

    echo '<tr style="text-align:left;">';
    while($row = mysql_fetch_array($result))
      {
        echo '<td style="text-align:left;">';  
      echo $row['name'];
      echo '</td>'; 
      echo '<td style="text-align:left;">'; 
      echo $row['email'];
         echo '</td>'; 
    echo '<td style="text-align:left;">'; 
      echo $row['tel'];
         echo '</td>'; 
     echo '<td style="text-align:left;">'; 
      echo $row['expdate'];
        echo '</td>'; 
      echo "</tr>";
      }

      ?>


    </table>

The problem is, the columns are being sorted quite randomly, it outputs the records and sorts them by this date order :

08-07-12
17-05-12
17-05-13
  • 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-04T19:40:41+00:00Added an answer on June 4, 2026 at 7:40 pm

    try

    order by STR_TO_DATE(expdate, '%d-%m-%y')
    

    (and next time use real Date format… for Date datas 😉 )

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

Sidebar

Related Questions

I have an optional field in a database that I'm pulling out using a
I am pulling in all the records from my customer database(mysql) for the last
I am pulling out record from the database and inserting them inside a dropdown
I'm pulling records out of a database, publishing their contents to a transactional MSMQ
I am pulling dates out of an Oracle database. They are set on a
I'm pulling records from database, and I have a filed called content_fr the _fr
i'm am pulling 10 out of 100 records back from the database and placing
We are using jquery for pagination. We are pulling millions of records from the
I am pulling data from one table, called analyzedCopy, and using it to over-rite
I am pulling my hair out on this one... I am using the ASIHTTPRequest

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.