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 7681597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:22:40+00:00 2026-05-31T18:22:40+00:00

i have this code right here: <select name=group> <option value=>Choose a group….</option> <?php foreach($groups

  • 0

i have this code right here:

<select name="group">
    <option value="">Choose a group....</option>
    <?php foreach($groups as $group):?>
        <option value="<?php echo $group['groupID']?>" selected="yes"><?php      echo     $group['name']?></option>

    <?php endforeach;?>
</select>

my question is how would i code the ‘option’ tag in my dropdown so that when i edit an existing data, the selected group(admin, users, moderators) of the data i will be editing will appear when i edit it.thanks.

  • 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-31T18:22:42+00:00Added an answer on May 31, 2026 at 6:22 pm

    The selected=”yes” HTML attribute of the option tag should be only one. You need to put it on the right group.

    Set a PHP variable like $selected_group that is true if the group is the right one, and print the selected attribute only for that group.
    Set it to false instead.

    For example, if your selected group id is putted as a request parameter called groupID you should use the code below:

    <select name="group">
        <option value="">Choose a group....</option>
        <?php foreach($groups as $group):?>
        <?php if ($group['groupID'] == $_REQUEST['groupID']) $selected_group = true; else $selected_group = false; ?>
            <option value="<?php echo $group['groupID']?>" <? if ($selected_group) echo 'selected="yes"'; ?>><?php      echo     $group['name']?></option>
    
        <?php endforeach;?>
    </select>
    

    You could set the chosen groupid as a array member inside $groups, for example:

    $groups[0]['selected'] = true;
    

    In this case change the line inside the loop like this one:

    <?php if ($group['selected']) $selected_group = true; else $selected_group = false; ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey I have this code right here: http://pastie.org/534470 And on line 109 I get
I have this code right now to get the row value from jquery grid..
I have this code which compiles and works as expected: class Right {}; class
I have this code <a href=#> <span style=border-right: medium none; class=Yes>Yes</span> </a> <a href=#>
Right now, I have this code where $obj_arr maybe contain array and an object.
Ok, if I have this right, my code can get cookies at a specific
I have code like this to move the player in my game left, right,
Right now, I have code that looks something like this: Private Sub ShowReport(ByVal reportName
Okay, right now I have a form that contains this select list: <%=Html.LabelFor(x =>
I have the following CSS code .editable:before { content: url(../images/icons/icon1.png); padding-right:5px; } this is

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.