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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.