Re: multidimensional array sort
| From: | Leif Gregory | Date: | Mon, 14 Mar 2005 19:22:09 +0000 |
| Subject: | Re: multidimensional array sort | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-210686@lists.php.net to get a copy of this message | ||
Hello Ashley,
Monday, March 14, 2005, 12:12:19 PM, you wrote:
A> I need to do a sort on the whole thing in such a way that:
A> a) all the Dir#'s are in ascending order, and
A> b) all the User#'s are in ascending order with each Dir#, and
A> b) all the File#'s are also in ascending order within each User#
http://us3.php.net/manual/en/function.array-multisort.php
It's funny, I was in the exact same boat this morning with regards to
generating a sign-in sheet for a class where I had pulled out all the
students into a multi-dimensional array and needing to sort them by
last name ascending. I was just about to delve into array-multisort
when it dawned on me that this would be the perfect opportunity for a
table join. So, I learned how to do a MySQL join (my first) a few
hours ago. It works great! Much less headache too.
$sqlRegisteredStudents="SELECT s.id, s.firstName, s.lastName, s.phone, s.email,
s.divisionOrFacility, s.supervisorName " .
"FROM " . $tbl_registrations . " r JOIN " .
$tbl_students . " s " .
"ON r.studentId = s.id " .
"WHERE courseId='" . $_POST['courseID'] .
"' " .
"ORDER BY s.lastName ASC";
--
Leif (TB lists moderator and fellow end user).
Using The Bat! 3.0.2.3 Rush under Windows XP 5.1
Build 2600 Service Pack 2 on a Pentium 4 2GHz with 512MB