Call-911 Posted February 24, 2011 Share Posted February 24, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/228661-contact-directory-database-pull-unique-values/ Share on other sites More sharing options...
onlyican Posted February 24, 2011 Share Posted February 24, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/228661-contact-directory-database-pull-unique-values/#findComment-1179035 Share on other sites More sharing options...
Call-911 Posted February 25, 2011 Author Share Posted February 25, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/228661-contact-directory-database-pull-unique-values/#findComment-1179506 Share on other sites More sharing options...
Muddy_Funster Posted February 25, 2011 Share Posted February 25, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/228661-contact-directory-database-pull-unique-values/#findComment-1179553 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.