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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:30:28+00:00 2026-06-04T03:30:28+00:00

I have select option in my page or drop down list,my problem is how

  • 0

I have select option in my page or drop down list,my problem is how can i set value
in my select option and this value is from the database,

here is my code.

  <select name="status" value="<?php echo $status; ?>" >

    <option value=""></option>
    <option value="public">public</option>
    <option value="private">private</option>
  </select>

on top of my html tag

   if(isset($_GET['status']))
    {
         $status = $_GET['status'];
     $sstatus="select .......";


   foreach($db->query($sstatus) as $rows)
    {
      $status= $rows['status'];
      ......
              ......
              ......
         }
   }

I tried modify my code and it’s seems working but my problem is that it has 2 same
value in the drop down list.

   <select name="status" >

    <option selected="selected"><?php echo $status; ?></option>
    <option value="public">public</option>
    <option value="private">private</option>
  </select>

it will show like this in my drop down list,my question for this is this is the right way
in displaying the values that comes from the database.

public
public
private

  • 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-04T03:30:30+00:00Added an answer on June 4, 2026 at 3:30 am
    <select name="status" >
        <option value=""></option>
        <option value="public"<?php if (isset($status) && $status === 'public') echo 'selected'; ?>>public</option>
        <option value="private"<?php if (isset($status) && $status === 'private') echo 'selected'; ?>>private</option>
     </select>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one drop-down list (<select> <option>) on page with id="coclevel1" . If current
Let's say I have the following drop down list. <select id=products> <option value=test1>Test1</option> <option
Ok here goes: I have a SELECT drop down option with US state names
I have a list like this: <select name=select_list_name id=list_id> <option value=>Select Option</option> <option value=value1>Option
I have a form that once you select from a drop-down list and select
i have a drop down list which is populated dynamically from database table i.e
I have a drop down list's select tag that looks like this: <select name=MyName
Background I have a payment page where the user can select from a list
I have a 5 drop-downs in my JSP page <select> <option></option> <option></option> <option></option> <option></option>
I have radcombo boxes on aspx page, and when I select any option from

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.