arrays, queries, birthdays, ...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stijn Goris

    arrays, queries, birthdays, ...

    hi all,

    I have this problem that I cant solve.

    I have created an agenda (http://28edegem.scoutnet.be/agenda.php) . The
    agenda contains events and birthdays of the members. I query the events and
    birthdays per month and sort them on date.
    This method works fine for the events since they are all for the same year
    (eg 2003) but doesnt work for the birthdays because someone born in
    1980-06-23 will be sorted before someone born in 1876-06-05 . This is a big
    problem because the person born on the fifth day wont be echo'ed . The
    problem can be easily be solved by only requesting the month and day part of
    the birthday. I'm not sure this is possible?

    If the above doesnt seem to work I can always order the array myself. How
    can I access a query array? I guess I can't use the fetch_row ?

    kind regards
    Stijn


  • Pedro

    #2
    Re: arrays, queries, birthdays, ...

    Stijn Goris wrote:
    [...][color=blue]
    >The
    >problem can be easily be solved by only requesting the month and day part of
    >the birthday. I'm not sure this is possible?
    >
    >If the above doesnt seem to work I can always order the array myself. How
    >can I access a query array? I guess I can't use the fetch_row ?[/color]

    Better to do it at the database side (for MySQL):

    $sql = "select month(birthdate ), dayofmonth(birt hdate), name, address"
    ." from agenda"
    ." where public=1"
    ." order by 1, 2";

    --
    "Yes, I'm positive."
    "Are you sure?"
    "Help, somebody has stolen one of my electrons!"
    Two atoms are talking:

    Comment

    • Kevin Thorpe

      #3
      Re: arrays, queries, birthdays, ...

      Stijn Goris wrote:[color=blue]
      > hi all,
      >
      > I have this problem that I cant solve.
      >
      > I have created an agenda (http://28edegem.scoutnet.be/agenda.php) . The
      > agenda contains events and birthdays of the members. I query the events and
      > birthdays per month and sort them on date.
      > This method works fine for the events since they are all for the same year
      > (eg 2003) but doesnt work for the birthdays because someone born in
      > 1980-06-23 will be sorted before someone born in 1876-06-05 . This is a big
      > problem because the person born on the fifth day wont be echo'ed . The
      > problem can be easily be solved by only requesting the month and day part of
      > the birthday. I'm not sure this is possible?
      >
      > If the above doesnt seem to work I can always order the array myself. How
      > can I access a query array? I guess I can't use the fetch_row ?[/color]


      order by dayofmonth(date )

      Comment

      Working...