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

The Archive Base Latest Questions

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

Using php and mysql-queries how can I produce HTML output in a YEAR-MONTH format.

  • 0

Using php and mysql-queries how can I produce HTML output in a YEAR-MONTH format.

I know we can use the MONTH() function if we want to sort it explicitly by month. But I want a both YEAR/MONTH sorting.

The table has an ID,DATA,TIME columns. I am able to output currently the YEAR/MONTH combination with a loop which just iterates from 1900 to 2100 and the sorting the rows in each of those year by month and displaying if we find any rows.

But this is naive approach and infact bad way to do it as its not modular.

How can I get a YEAR-MONTH wise sorting output in HTML using the TIME column’s data

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

    Like the MySQL MONTH() function, there is also a YEAR() function. Additionally, you can sort on multiple columns in a single SELECT statement and by doing so you will sort everything based on the first column, then sub-sort within each group.

    So, to get Year/Month sorting, you can use the following ORDER BY clause:

    ORDER BY YEAR(`TIME`), MONTH(`TIME`)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use a graph database using php. Can you point out some
Using PHP and MySQL, I want to select only 6 rows from table which
What is the most correct way to perform MySQL Queries using PHP? I read
I'm coding using PHP PDO and MySQL. In that context, can I write a
I'm using PHP PDO to run queries. I have the following function: protected function
Using PHP / MySQL all encoded up as UTF, we have recently had to
I am currently using PHP/MySQL and the jQuery timeago plugin. Basically, I need to
I'm using PHP/MySql. If I have two tables (hypothetically) as follows: id name and
i have created a forum using php/mysql and users login through facebook using php
Im trying to create a iPhone Objective C login page using PHP/MySQL to authenticate.

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.