Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8890277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:27:53+00:00 2026-06-14T22:27:53+00:00

I think this is probably a simple one, but I am just trying to

  • 0

I think this is probably a simple one, but I am just trying to think of the most effective way of doing what I want.

What I have, is a page that allows a manager, to edit user’s within their own department.
This works fine at its most basic, where by I run a query to return all users WHERE Department=managers department.

This will return all users within the same department. What I would like to do, is expand upon that, as some managers are responsible for several departments, and want to be able to edit users from various departments.

My thinking was to have a department table, with an entry for the user. There would then be a column for each department, and I would set the value to Yes for each department the manager is responsible for.

The tricky part would then be to adjust the query based on that information. What do you all think would be the best way to query the row, and for each field with a value of Yes, add on the department as an option in the query

I could do:

$row = mysql_fetch_assoc($result);
If($row['dept1'] == 'Yes') {
    $query. = " OR Department=dept1";
}
if($row['dept2'] == 'Yes') {
    $query. = " OR Department=dept2";
}

This would work I imagine, but would mean that I would need to manually go in and hard code a department if we were to add one or remove one etc.

Is there a more elegant solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:27:54+00:00Added an answer on June 14, 2026 at 10:27 pm

    I don’t think there can be a better solution, but a cleaner one is the following:

      WHERE department IN (dept1,dept2,dept3...)
    

    and you make an array of departments you want to include, and then implode() the array into “IN ()” phrase of the query, like this:

        ... IN (implode(",", $array))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably quite simple to do.. but I just can't think of how
Sorry if this is probably a simple fix but I can't think of one.
Ok, I think this is probably an easy question but for the life of
I think this could be a very easy question for you. But I have
I think this is a simple and a silly question. I have included a
Okay, this is (probably) a very simple question, but I am afraid I know
Probably simple question and I'm just missing something, but I'm stuck out of ideas.
This is probably a stupidly simple question, but I'm stuck. I had created a
I know this is probably something so simple that I am just not able
It should quite simple algorithm, but I just can't get around it. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.