Jump to content

Multiple Dates


BrandonE97

Recommended Posts

this is a matter of keeping a running tab on what date you're currently on, and only echoing it if it's different from the last:

 

while ($stuff = stuff)
{
  // echo this row's value if it differs from the last value
  if ($last_loop_val != $stuff['this_loop_val'])
  {
    echo 'new value: '.$stuff['this_loop_val'];
  }

  // do your stuff here

  // assign the last value to this value for the next loop
  $last_loop_val = $stuff['this_loop_val'];
}

 

EDIT:  you and your speedy typing, barand.

Link to comment
https://forums.phpfreaks.com/topic/62897-multiple-dates/#findComment-313111
Share on other sites

you'd have to translate your month into its ordered value, and order on that:

 

SELECT stuff, (CASE DATE_FORMAT(row_date, 'something') WHEN something THEN 1, WHEN something_else THEN 2, WHEN something_even_elser THEN 3) AS order_key ORDER BY order_key ASC

 

what you use in DATE_FORMAT() depends on in what way you want to assign orders.  if it's month, you'll probably want to use %b or %c.  see the manual for the differences.

 

don't know if this is the most efficient way, so i'm hoping an SQL guy comes around and suggests a better way (or validates this one).

Link to comment
https://forums.phpfreaks.com/topic/62897-multiple-dates/#findComment-313119
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.