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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:00:24+00:00 2026-06-03T07:00:24+00:00

I have tried to search for a solution to my problem, but I’m not

  • 0

I have tried to search for a solution to my problem, but I’m not really sure what I am searching for, so I haven’t had much luck.

I have a simple MySQL database with one table called “activities”. In that table I have fields for “start_date”, “activity_description”, and “activity_location”.

I am trying to do an MySQL query using PHP and display the results in ascending date order, but have all the activities that fall on the same date separated by a heading.

For example I am trying to achieve the following.

2012-05-03

  • Take dog for walk
  • Park
  • Go out for dinner
  • Little Italian Restaurant

2012-05-04

  • Get Car Serviced
  • Johns Auto and Mechanical

2012-05-05

  • Do Grocery Shopping
  • Fresh Supermarket
  • Go See Movie
  • MegaPlex Cinemas
  • Meet Up With Sam
  • Hole In The Wall Bar

So far I have worked out that the MQSQL query needs to be something like this:

$result = mysql_query("SELECT * FROM activities ORDER BY start_date ASC")

And then to display the results I need to do this:

while($row = mysql_fetch_array($result))
{
echo 
  '<strong>' .  
  $row['start_date'] . 
  '</strong>' .
  '<ul><li>' . 
  $row['activity_description'] .
  '</li><li>' .     
  $row['activity_location'] . 
  '</li></ul>'; 
 }              

Which gives the results like so, repeating the date for each result:

2012-05-03

  • Take dog for walk
  • Park

2012-05-03

  • Go out for dinner
  • Little Italian Restaurant

2012-05-04

  • Get Car Serviced
  • Johns Auto and Mechanical

2012-05-05

  • Do Grocery Shopping
  • Fresh Supermarket

2012-05-05

  • Go See Movie
  • MegaPlex Cinemas

2012-05-05

  • Meet Up With Sam
  • Hole In The Wall Bar

Could anyone give me some tips on how to only echo the ‘start_date’ once for a particular date, and then echo it again when the date is different from the previous date?

Any tips, no matter how cryptic would be greatly appreciated. Thanks.

  • 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-03T07:00:26+00:00Added an answer on June 3, 2026 at 7:00 am

    Just track the date.

    You define a date with something that would not appear like a date in the past or just false.

    Running through the lis you only print your heading when the date has changed and save the new date. Just like this:

    $currentDate = false;
    while($row = mysql_fetch_array($result))
    {
    if ($row['start_date'] != $currentDate){
     echo
      '<strong>' .  
      $row['start_date'] . 
      '</strong>' ;
      $currentDate = $row['start_date'];
    }
     echo 
      '<ul><li>' . 
      $row['activity_description'] .
      '</li><li>' .     
      $row['activity_location'] . 
      '</li></ul>'; 
     }  
    

    Regards,
    STEFAN

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

Sidebar

Related Questions

I have tried several things so far, but I haven't had much luck yet.
I've tried to search for a solution for this, but have had no joy:
I have tried this but it does not work (even if I specify .wav
I have tried to search first but couldn't find exactly what I need. I
I have a problem I tried solving on my own, but didn't get far
Help please, After numerous hours searching for the solution to my problem i have
I have tried to find a solution to what I want to do but
I have tried to use mysql fulltext search in my intranet. I wanted to
Have tried to find solutions for this and can't really come up with anything.
I have tried quite a few codes but none of them seem to work

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.