Jump to content

Contact Directory Database - Pull Unique Values


Call-911

Recommended Posts

Hello All,

 

I have a contact directory database. It has all the employees of my company (name, phone, email, department, building, etc).

 

Say on one page I have the Marketing Department, and I want to say:

"The Marketing Department Director is ________"

 

How would I assign that value from the database? Do I want to put in a unique "keyword" field in the database, but then how would I store all the values automatically on the page?

 

I see pages where I would want to list the Marketing Director, and his secretary, then another page with the Sales Director, and his secretary, etc....  all with being able to change the values in the database, and it changing across all the pages instantly.

 

Do I need to say on every page "select * from database where keyword = marketingdirector" and then store that result as a variable? It seems unpractical to repeat that a few times for each different person I want to list.

 

Is there a better way to do this then I'm thinking?

 

Thanks all!

Link to comment
Share on other sites

You have to look at the bigger picture

IF every category as

CATEGORY Director

CATEGORY Secretary

 

then you can do a simple solution of having an INT in the table for ranking

1 = DIRECTOR

2 = SECRETARY

ect ect

 

If the position can be different per category a better solution

Still keep the Ranking

1 = TOP DOG

2 = NEXT ONE DOWN

then also have a varchar containing there rank

 

Order by the rank, get the rank name and sorted.

Link to comment
Share on other sites

But then how would I only choose one value on a page and not all. Say I want to have a marketing director's bio page. I only want to select his row from the database and stored as a value, not all 2000 staff.

 

I want to use one database for everything, but then pull out people as needed.

 

The only way I can figure out how to do that is to do a "SELECT * FROM table WHERE keyword = 'marketingdirectory'"

 

But I don't want to do for every single person I need to show.

Link to comment
Share on other sites

there is no better way than to do it by

Select name, phone, email, department, building FROM tablename WHERE criteria is met

There are otther ways of doing it, but not better ones.  You could do a single SELECT statement on a page of it's own which can populate an array, you could then pass this array to $_SESSION and reffer back to it from any page.  But you would only do that if you wanted to use massive amounts of bandwith and grind your site to a halt.

 

What is your issue with selecting only what you need, only when you need it?  Why does that not strike you as the most sensible way to do things?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.