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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:42:24+00:00 2026-05-15T20:42:24+00:00

Hello I currently have this PHP Script <?php if($purchase_dates != FALSE){?> <?php foreach($purchase_dates as

  • 0

Hello I currently have this PHP Script

        <?php if($purchase_dates != FALSE){?>
                        <?php foreach($purchase_dates as $id=>$outer_value) { ?>
                        <!-- Output the date here -->
                          <!-- Start Purchase table -->
                          <?
                          $date = strtotime($outer_value['date_purchased']);
                          $data = date('F jS Y', $date);
                          ?>

                          <h3></h3>
                          <!-- Start inner loop -->
                          <?php foreach($purchases as $id=>$inner_value) { ?>
                           <?php if($inner_value['date_purchased'] == $outer_value['date_purchased']) { ?>
                                <div class="row"> 
                                    <ul> 
                                        <li class="id"><a href="/search/cv/<?=$inner_value['code'];?>"><?=$inner_value['code'];?></a></li> 
                                        <li class="name"><a href="/search/cv/<?=$inner_value['code'];?>"><?=$inner_value['firstname'];?> <?=$inner_value['surname'];?></a></li>
                                        <li class="download"><a href="">Download PDF</a></li>
                                        <div class="disp"> 
                                            <li class="location"><?=$inner_value['city'];?></li> 
                                            <li class="status"><?=$job_status[$inner_value['job_status']];?></li> 
                                            <li class="education"><?=$education_types[$inner_value['education_level']]['nice_name'];?></li>
                                            <li class="role">
                                                <?php
                                                $out = array();
                                                if($inner_value['is_contract'] == 'Y') $out[]="Contract";
                                                if($inner_value['is_permanent'] == 'Y') $out[]="Permanent";
                                                if($inner_value['is_temporary'] == 'Y') $out[]="Temporary";
                                                echo implode(", ",$out);
                                                ?>
                                            </li> 

                            <li class="salary"><?=$salaries[$inner_value['expected_salary_level']]['nice_name'];?></li> 
                                        </div>
                                    </ul> 
                                </div>
                           <?php  } ?>
                          <?php  } ?>
                          <!-- End inner loop -->
                        <?php } ?>
                        <?php }?>
                        <!-- End Outer Tree Loop -->

This generates something that looks like this,

22nd July
Purchase1

22nd July
Purchase 2

18th July
Purchase 3

18th July
Purchase 4

My question is, I want to group all the purchases that are on the same under that date and also if that date is todays date I want to replace ’23rd July’ with ‘Todays Purchases’

I am already using groupby in my SQL

  • 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-15T20:42:25+00:00Added an answer on May 15, 2026 at 8:42 pm

    The easiest way to group by a date is to add an extra dimension to your arrays, so all entries that belong to the same date are in the same subarray. Then you just need to loop twice:

    foreach($data as $purchase_date => $purchases){
        // Print date
        foreach($purchases as $id=>$inner_value){
            // Print purchase
        }
    }
    

    You appear to be using Unix timestamps for dates, so you can simply use date() to strip hours, minutes and seconds:

    if( date('Y-m-d')==date('Y-m-d', $purcharse_date) ){
        // Today
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 501k
  • Answers 501k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer TWinSocketStream has a timeout. You basically create a blocking socket,… May 16, 2026 at 2:25 pm
  • Editorial Team
    Editorial Team added an answer Your URI doesn't look correct, it should be either file://birds/birds.txt… May 16, 2026 at 2:25 pm
  • Editorial Team
    Editorial Team added an answer If your app crashes, it'll automatically write a crash log… May 16, 2026 at 2:25 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Hello everyone Masters Of Web Delevopment :) I have a piece of PHP script
Hello I have a bizarre problem with sprintf . Here's my code: void draw_number(int
Thanks for all the great answers, this helps a lot! Hello, I need some
This is a longshot but I have a file with something like this: document
I'm trying to enable some basic commands via email. Currently I have shared hosting
I have a form like this: <form id=form_main name=form_main action=/search/ target=iframe001 method=get onSubmit=reset_and_subm();> Enter
Hello i have just started learning mvc2 and im having a problem with the
Hello Friends i have the following query which defeat the very purpose. A day
Hello I am using autocomplete to allow users to search venues stored in a
I am have a table that shows the user suggestions that they have recieved

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.