[PHP] Array Sorting, 2 items...

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default RE: [PHP] Array Sorting, 2 items...

    > -----Original Message-----
    > From: Dan Joseph [mailto:djoseph@duhq.us]
    > Sent: 22 July 2003 16:29
    >
    > Yeah, I did get it from a mysql_fetch_array(). I have:
    >
    > ORDER BY
    > payment_methods.ba_type ASC,
    > loan_info.loan_number ASC
    >
    > However, what it does is first orders it by ba_type, then it
    > goes through
    > and re-orders it be loan_number, not keeping the ba_type
    > order intact. I
    > would have much rather handled it all with the SQL, but it
    > just doesn't seem
    > to work. Here's the entire query:
    >
    > SELECT payment_methods.ba_type, loan_info.loan_number, loan_info.id AS
    > loan_id, cust_info.first_name, cust_info.last_name,
    > transactions.approved_date, payment_types.type FROM
    > loan_info, cust_info,
    > transactions, payment_methods, payment_types WHERE
    > payment_methods.id =
    > transactions.payment_method AND payment_types.id =
    > transactions.trans_type
    > AND cust_info.id = loan_info.cust_id AND transactions.loan_id
    > = loan_info.id
    > AND transactions.trans_type = 1 AND (transactions.approved_date >=
    > '2003-07-09 00:00:00' AND transactions.approved_date <= '2003-07-22
    > 23:59:59') AND (loan_info.loan_number LIKE '101%' OR
    > loan_info.loan_number
    > LIKE '136%' OR loan_info.loan_number LIKE '707%') GROUP BY
    > loan_info.id
    > ORDER BY loan_info.loan_number ASC
    >
    > Maybe I'm doing something wrong there?
    Well, erm, maybe I've got the wrong glasses on today, or maybe you've made a
    cut'n'paste boo-boo, but it sure looks to me like the ORDER BY clause on
    your entire query is not the same as the one you posted above.

    Cheers!

    Mike

    ---------------------------------------------------------------------
    Mike Ford, Electronic Information Services Adviser,
    Learning Support Services, Learning & Information Services,
    JG125, James Graham Building, Leeds Metropolitan University,
    Beckett Park, LEEDS, LS6 3QS, United Kingdom
    Email: [email]m.ford@lmu.ac.uk[/email]
    Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
    Mike Ford Guest

  2. Similar Questions and Discussions

    1. Sorting array vs sorting paginated array
      ....pulling in a long list of photos in a gallery, and I have a sort function working within the pages of data fine. I need to bring it back out of...
    2. Sorting tree items manually
      I am trying to allow the user a way of shifting through items in a tree 2 levels deep. This will give the user a chance to order the items within...
    3. Array Sorting
      Hey everyone, I figured someone out there must have come across the need for this before, so rather than continue banging my head against the...
    4. client side sorting of datagrid items
      Does anyone know if there's code out there to manage client-side sorting of datagrid items? I'd like to be able to fill a datagrid with records...
    5. Array Sorting, 2 items...
      Hi, Trying to accomplish: I want to sort my array by two columns. The array is setup: Array ( => Array (
  3. #2

    Default Re: [PHP] Array Sorting, 2 items...

    * Thus wrote Dan Joseph (djoseph@duhq.us):
    > Eek... Yes, I did past it wrong...
    >
    > SELECT payment_methods.ba_type, loan_info.loan_number, loan_info.id AS
    > loan_id, cust_info.first_name, cust_info.last_name,
    > transactions.approved_date, payment_types.type FROM loan_info, cust_info,
    > transactions, payment_methods, payment_types WHERE payment_methods.id =
    > transactions.payment_method AND payment_types.id = transactions.trans_type
    > AND cust_info.id = loan_info.cust_id AND transactions.loan_id = loan_info.id
    > AND transactions.trans_type = 1 AND (transactions.approved_date >=
    > '2003-07-09 00:00:00' AND transactions.approved_date <= '2003-07-22
    > 23:59:59') AND (loan_info.loan_number LIKE '101%' OR loan_info.loan_number
    > LIKE '136%' OR loan_info.loan_number LIKE '707%') GROUP BY loan_info.id
    > ORDER BY payment_methods.ba_type ASC, loan_info.loan_number ASC
    >
    > That's the right query. Anything wrong with that? Shouldn't that give me
    > the sort I'm looking for without having to do a usort?
    Correct, that should sort properly.

    If that isn't workin I would get on the database servers mailing list
    (if they have one).


    Curt
    --
    "I used to think I was indecisive, but now I'm not so sure."
    Curt Zirzow Guest

  4. #3

    Default RE: [PHP] Array Sorting, 2 items...

    Uhhh, I could have sworn I posted the right one, here it is again...

    SELECT payment_methods.ba_type, loan_info.loan_number, loan_info.id AS
    loan_id, cust_info.first_name, cust_info.last_name,
    transactions.approved_date, payment_types.type FROM loan_info, cust_info,
    transactions, payment_methods, payment_types WHERE payment_methods.id =
    transactions.payment_method AND payment_types.id = transactions.trans_type
    AND cust_info.id = loan_info.cust_id AND transactions.loan_id = loan_info.id
    AND transactions.trans_type = 1 AND (transactions.approved_date >=
    '2003-07-09 00:00:00' AND transactions.approved_date <= '2003-07-22
    23:59:59') AND (loan_info.loan_number LIKE '101%' OR loan_info.loan_number
    LIKE '136%' OR loan_info.loan_number LIKE '707%') GROUP BY loan_info.id
    ORDER BY payment_methods.ba_type ASC, loan_info.loan_number ASC

    Any ideas?

    -Dan Joseph
    > -----Original Message-----
    > From: Ford, Mike [LSS] [mailto:M.Ford@lmu.ac.uk]
    > Sent: Tuesday, July 22, 2003 11:39 AM
    > To: 'Dan Joseph'; [email]php-general@lists.php.net[/email]
    > Subject: RE: [PHP] Array Sorting, 2 items...
    >
    >
    > > -----Original Message-----
    > > From: Dan Joseph [mailto:djoseph@duhq.us]
    > > Sent: 22 July 2003 16:29
    > >
    > > Yeah, I did get it from a mysql_fetch_array(). I have:
    > >
    > > ORDER BY
    > > payment_methods.ba_type ASC,
    > > loan_info.loan_number ASC
    > >
    > > However, what it does is first orders it by ba_type, then it
    > > goes through
    > > and re-orders it be loan_number, not keeping the ba_type
    > > order intact. I
    > > would have much rather handled it all with the SQL, but it
    > > just doesn't seem
    > > to work. Here's the entire query:
    > >
    > > SELECT payment_methods.ba_type, loan_info.loan_number, loan_info.id AS
    > > loan_id, cust_info.first_name, cust_info.last_name,
    > > transactions.approved_date, payment_types.type FROM
    > > loan_info, cust_info,
    > > transactions, payment_methods, payment_types WHERE
    > > payment_methods.id =
    > > transactions.payment_method AND payment_types.id =
    > > transactions.trans_type
    > > AND cust_info.id = loan_info.cust_id AND transactions.loan_id
    > > = loan_info.id
    > > AND transactions.trans_type = 1 AND (transactions.approved_date >=
    > > '2003-07-09 00:00:00' AND transactions.approved_date <= '2003-07-22
    > > 23:59:59') AND (loan_info.loan_number LIKE '101%' OR
    > > loan_info.loan_number
    > > LIKE '136%' OR loan_info.loan_number LIKE '707%') GROUP BY
    > > loan_info.id
    > > ORDER BY loan_info.loan_number ASC
    > >
    > > Maybe I'm doing something wrong there?
    >
    > Well, erm, maybe I've got the wrong glasses on today, or maybe
    > you've made a
    > cut'n'paste boo-boo, but it sure looks to me like the ORDER BY clause on
    > your entire query is not the same as the one you posted above.
    >
    > Cheers!
    >
    > Mike
    >
    > ---------------------------------------------------------------------
    > Mike Ford, Electronic Information Services Adviser,
    > Learning Support Services, Learning & Information Services,
    > JG125, James Graham Building, Leeds Metropolitan University,
    > Beckett Park, LEEDS, LS6 3QS, United Kingdom
    > Email: m.ford@lmu.ac.uk
    > Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
    >
    > --
    > PHP General Mailing List (http://www.php.net/)
    > To unsubscribe, visit: http://www.php.net/unsub.php
    >
    Dan Joseph Guest

Posting Permissions

  • You may not post new threads
  • You may 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