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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:56:10+00:00 2026-05-23T17:56:10+00:00

I have a an array: Array ( [0] => Array ( [id] => 53

  • 0

I have a an array:

Array
(
    [0] => Array
        (
            [id] => 53
            [product] => something
            [price] =>  £78
            [quantity] => 23
            [time] => 2011-07-15 20:29:21
        )

    [1] => Array
        (
            [id] => 52
            [product] => product
            [price] => £89
            [quantity] => 1
            [time] => 2011-07-14 00:51:57
        )

    [2] => Array
        (
            [id] => 51
            [product] => product
            [price] => £89
            [quantity] => 1
            [time] => 2011-07-14 00:51:37
        ))

I got this using the following sql statement:

select * from some_table GROUP BY time DESC

I want to display the results ordered by date, with the date as a heading:

e.g.

**2011-07-15**
all array elements for above date go here

**2011-07-15**
all array elements for above date go here

I thought about doing a seperate statement for each seperate day, but that sounds wrong. Is there a better way?

  • 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-05-23T17:56:10+00:00Added an answer on May 23, 2026 at 5:56 pm

    ORDER BY Time in your query, like this:

    select * from some_table ORDER BY time DESC
    

    Then loop in PHP:

    $last_date = 0;
    while($row = mysql_fetch_assoc($result)){
        $date = date('Y-m-d', strtotime($row['time']));
        if($date != $last_date)
            echo '**'.$date.'**';
        $last_date = $date;
        echo '<br />';
        echo 'Id: '.$row['Id'];
        echo 'Product: '.$row['product'];
        echo 'Price: '.$row['price'];
        echo 'Quantity: '.$row['quantity'];
        echo '<br /><br />';
    }
    

    If you’re ouputting to a console instead of an HTML page then replace the '<br \>' with "\n"

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

Sidebar

Related Questions

I am using CakePHP and i have something like: PRODUCT -------> PRODUCT_CATEGORY <---------- CATEGORY
I have a object (product), with a property of type 'array' e.g. product.tags =
I have array of select tag. <select id='uniqueID' name=status> <option value=1>Present</option> <option value=2>Absent</option> </select>
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
I have this code, $sqlstr = mysql_query( SELECT * FROM sales where passport =
When I obtain a field 'text' of an array I have to do something
I have the following three models Product , Order , OrderDetail . Product has
Imagine I have table like this: id:Product:shop_id 1:Basketball:41 2:Football:41 3:Rocket:45 4:Car:86 5:Plane:86 Now, this
I have the following array called $order (as printed out by print_r): stdClass Object
I have a product with array of prices. I want that based on the

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.