Professional Web Applications Themes

arrays, queries, birthdays, ... - PHP Development

hi all, I have this problem that I cant solve. I have created an agenda ([url]http://28edegem.scoutnet.be/agenda.php[/url]) . 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 ...

  1. #1

    Default arrays, queries, birthdays, ...

    hi all,

    I have this problem that I cant solve.

    I have created an agenda ([url]http://28edegem.scoutnet.be/agenda.php[/url]) . 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


    Stijn Goris Guest

  2. #2

    Default Re: arrays, queries, birthdays, ...

    Stijn Goris wrote:
    [...]
    >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 ?
    Better to do it at the database side (for MySQL):

    $sql = "select month(birthdate), dayofmonth(birthdate), 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:
    Pedro Guest

  3. #3

    Default Re: arrays, queries, birthdays, ...

    Stijn Goris wrote:
    > hi all,
    >
    > I have this problem that I cant solve.
    >
    > I have created an agenda ([url]http://28edegem.scoutnet.be/agenda.php[/url]) . 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 ?

    order by dayofmonth(date)

    Kevin Thorpe Guest

Similar Threads

  1. Rows, Cols, Queries and Arrays
    By Krogman in forum Coldfusion - Advanced Techniques
    Replies: 2
    Last Post: April 8th, 12:51 PM
  2. Replies: 1
    Last Post: October 14th, 11:56 PM
  3. #25827 [Fbk->Opn]: PHP LDAP queries against Active Directory return incomplete arrays
    By pennington at rhodes dot edu in forum PHP Development
    Replies: 2
    Last Post: October 14th, 06:08 PM
  4. Replies: 2
    Last Post: October 14th, 04:27 PM
  5. #25827 [Bgs->Opn]: PHP LDAP queries against Active Directory return incomplete arrays
    By pennington at rhodes dot edu in forum PHP Development
    Replies: 0
    Last Post: October 13th, 03:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139