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 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

Related Questions

Regarding Uploadify Hello, Currently I have a PHP only upload script and I'm planning
Hello I currently have this code checking if a cookie exists, it works all
Currently I am doing this: I have text that looks like: Hello ${user.name}, this
Currently (in PHP) I have the following regex pattern: \[(.*) (.*)=(.*)\] This matches [doSomething
this is my current php-script. $mystr = 'Hello world. The world is nice'; substr_count($mystr,
-Hello, looking for some help. We currently have a winform app used to do
Hello I have a WinForm app that generates a ton of data. Currently I
Hello Ruby/Rails/Merb developers! Im currently working on a web project that will have a
Hello Im currently writing a product syncronisation script for magento. I know how to
Hello I'm currently on Day 2 of Jeffrey Way's Codeigniter tutorial. In this screencast

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.