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

  • SEARCH
  • Home
  • 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 7062001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:32:32+00:00 2026-05-28T04:32:32+00:00

I am creating an admin menu for a site and I have several drop

  • 0

I am creating an admin menu for a site and I have several drop down lists that need to be created for each different field with the default selected option being different for each record that appears (this is very similar idea to the permission admin panel in phpBB). In other words, I have a table that lists all of the groups that a user could belong to, and in each row there are select menus for changing the permissions of that group. I am currently using functions for each different set of menus that looks like this:

function rfiPermissions($x){
$query = "SELECT rfi_permission FROM groups WHERE id = '$x'";
$result = mysql_query($query) or die();
$row = mysql_fetch_array($result);
$perm = $row[0];
$option = array();
$option[0] = "<option value='0'>None</option>";
$option[1] = "<option value='1'>Basic</option>";
$option[2] = "<option value='2'>Supplemental</option>";
$option[3] = "<option value='3'>Full</option>";
switch($perm){
    case 0:
        echo $option[0].$option[1].$option[2].$option[3];
        break;
    case 1:
        echo $option[1].$option[0].$option[2].$option[3];
        break;
    case 2:
        echo $option[2].$option[1].$option[0].$option[3];
        break;
    default:
        echo $option[3].$option[1].$option[0].$option[2];
        break;
}
}

I have been trying to figure out a more stream-lined way of doing this because I need to implement this many more times in my site, but I have been unable to do so. Is there a better way of doing this where I can simply pass an array of what the options need to be into a function, then echo the one value from the db, remove it from the array, then echo the rest of the options?

  • 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-05-28T04:32:32+00:00Added an answer on May 28, 2026 at 4:32 am

    It is easier to set the selected attribute with php than to change the order. Plus, as a user I like consistency and if I looked at a drop down and the order changed each time I looked at it I would be frustrated.

    $option[0] = "<option value='0' ".($perm==0 ? " selected " : "") .">None</option>";
    $option[1] = "<option value='1' ".($perm==1 ? " selected " : "") .">Basic</option>";
    $option[2] = "<option value='2' ".($perm==2 ? " selected " : "") .">Supplemental</option>";
    $option[3] = "<option value='3' ".($perm==3 ? " selected " : "") .">Full</option>";
    

    This is done in if short hand and can be expanded for readability

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an admin form I'm creating that has four different areas with similar
So I am creating a website that I want to have an admin directory
How to add app item to main django admin site menu without creating any
I have a problem when creating a menu in WPF. What happens is that
I have a product admin web site that has been generated using ASP.NET Dynamic
I'm creating an admin module for my client that gives them access to some
I am creating one admin page where I have multiple textboxes.when I enter the
I am creating a website with multiple sections--admin, client, user, and anonymous--each user group
I'm creating a static site generator with a dynamic admin backend for one user.
At the moment, I am creating some kind of admin panel/backend for my site.

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.