You are here: Re: [PHP] multidimensional array sort « PHP « IT news, forums, messages
Re: [PHP] multidimensional array sort

Posted by Leif Gregory on 03/14/05 21:22

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация