Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Crazylife's avatar

How to loop value based on date into day column in table?

The price date is get from

 GROUP_CONCAT(CONCAT(price, ' / ', date)) AS price_date

$r->price_date // data output:  1.00 / 2013-07-13 14:35,2.00 / 2013-07-13 14:35

@foreach($results as $r)
   <?php
       $price_n_date = explode(',',  $r->price_date);      
         foreach ($price_n_date as $value) {
           list($price,$date) = explode ('/',$value)
        // How can i compare with day and display value of the day to the column?
         }
  ?>
@endforeach

I have a table which generate 31 column of days 1st to 31st in table header. In tbody, i will loop an item with it's price and date which will be displayed in the day column from 1st to 31st, if the day of date and the day column matched then only show value else will show a dash.

It is something like attendance list, but i am going to show the price changes of the item on the month based on day.

I am trying to display all the value with following day stored in database.

0 likes
0 replies

Please or to participate in this conversation.