Array in PHP.

Hello I have a db that has the following data:

Name       Access Level       Mailbox
Tom           Admin                 100
Jones         Admin                 101
Tim            Sales                   102
Jack            Sales                  103
Sarah         Manager           104
James        Manager           105

I am looking for a script that can give me the following output:

Admin  Mailbox
Tom                 100
Jones               101

Sales    Mailbox
Tim                   102
Jack                   103

Manager Mailbox
Sarah                  104
James                  105

Thanks for the help.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
I would probably do three separate SELECT queries, something like these:

SELECT Name, Mailbox FROM myTable WHERE accessLevel = 'Admin' ORDER BY Name DESC
SELECT Name, Mailbox FROM myTable WHERE accessLevel = 'Sales' ORDER BY Name DESC
SELECT Name, Mailbox FROM myTable WHERE accessLevel = 'Manager' ORDER BY Name DESC

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
aej1973Author Commented:
Hello Ray, I looking for some help in writing some nested foreach statements. How can I do this?

Ray PaseurCommented:
Why would you write nested foreach() statements?  What is the objective?
aej1973Author Commented:
Got your point. Made the change, thanks.

Ray PaseurCommented:
Great - I think it will be easier to program and also to understand the intent of the programming when you revisit it later!  Thanks for using E-E, ~Ray
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.