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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:42:38+00:00 2026-05-25T10:42:38+00:00

I have a PHP form which I use to edit a record in the

  • 0

I have a PHP form which I use to edit a record in the MySQL data base and it has a drop down list of values I would like to set the option that is held in the database to be the first one in the list so that if the user doesn’t want to change the option then the database will not get overwritten with the default option

Can any one suggest a really simple solution?

Based on comment I do need help with the ability to set the selected value my HTML select

<select id="inputRegion" name="inputRegion">
<option name="inputRegion" id="inputRegion" value="Scotland">Scotland</option>
<option name="inputRegion" id="inputRegion" value="North West">North West</option>
<option name="inputRegion" id="inputRegion" value="North East">North East</option>
<option name="inputRegion" id="inputRegion" value="Yorkshire and Humberside">Yorkshire & Humberside</option>
<option name="inputRegion" id="inputRegion" value="East Midlands">East Midlands</option>
<option name="inputRegion" id="inputRegion" value="East Anglia">East Anglia</option>
<option name="inputRegion" id="inputRegion" value="London">London</option>
<option name="inputRegion" id="inputRegion" value="South East">South East</option>
<option name="inputRegion" id="inputRegion" value="South West">South West</option>
<option name="inputRegion" id="inputRegion" value="Wales">Wales</option>
<option name="inputRegion" id="inputRegion" value="West Midlands">West Midlands</option>
<option name="inputRegion" id="inputRegion" value="Northern Ireland">Northern Ireland</option>
</select>

My php comes from a query and then can get the current record’s region using;

<?php echo $contact['Region']; ?>
  • 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-25T10:42:39+00:00Added an answer on May 25, 2026 at 10:42 am

    If it’s a small dropdown this is quick and easy

    <label>Type: </label>
                    <?php
                        if(isset($item->type_id))
                            $tid = $item->type_id;
                        else
                            $tid = 1; // Set this to your preferred default
                    ?>
                    <select name="type">
                        <option value="1" <?php if($tid == 1) echo ' selected' ?>>Type 1</option>
                        <option value="2" <?php if($tid == 2) echo ' selected' ?>>Type 2</option>
                        <option value="3" <?php if($tid == 3) echo ' selected' ?>>Type 3</option>
                    </select>
    

    If it’s a bigger dropdown write a php function to create the dropdown using an iterative approach

    EDIT * is this right as it is now defaulting to the $tid

                            <?php
                                    if(isset($contact['Region']))
                                        $tid = $contact['Region'];
                                    else
                                        $tid = 'South East'; // Set this to your preferred default
                                ?>          
                                <select id="inputRegion" name="inputRegion">
                                        <option name="inputRegion" id="inputRegion" value="Scotland" <?php if($tid == 'Scotland') echo ' selected' ?>>Scotland</option>
                                        <option name="inputRegion" id="inputRegion" value="North West" <?php if($tid == 'North West') echo ' selected' ?>>North West</option>
                                        <option name="inputRegion" id="inputRegion" value="North East" <?php if($tid == 'North East') echo ' selected' ?>>North East</option>
                                        <option name="inputRegion" id="inputRegion" value="Yorkshire and Humberside" <?php if($tid == 'Yorkshire and Humberside"') echo ' selected' ?>>Yorkshire & Humberside</option>
                                        <option name="inputRegion" id="inputRegion" value="East Midlands" <?php if($tid == 'East Midlands') echo ' selected' ?>>East Midlands</option>
                                        <option name="inputRegion" id="inputRegion" value="East Anglia" <?php if($tid == 'East Anglia') echo ' selected' ?>>East Anglia</option>
                                        <option name="inputRegion" id="inputRegion" value="London" <?php if($tid == 'London') echo ' selected' ?>>London</option>
                                        <option name="inputRegion" id="inputRegion" value="South East" <?php if($tid == 'South East') echo ' selected' ?>>South East</option>
                                        <option name="inputRegion" id="inputRegion" value="South West" <?php if($tid == 'South West') echo ' selected' ?>>South West</option>
                                        <option name="inputRegion" id="inputRegion" value="Wales" <?php if($tid == 'Wales') echo ' selected' ?>>Wales</option>
                                        <option name="inputRegion" id="inputRegion" value="West Midlands" <?php if($tid == 'West Midlands') echo ' selected' ?>>West Midlands</option>
                                        <option name="inputRegion" id="inputRegion" value="Northern Ireland" <?php if($tid == 'Northern Ireland') echo ' selected' ?>>Northern Ireland</option>
                                </select>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form on which I POST the data with PHP. When the
I have some grid which use form edit. But after edit success then page
I have a php file that contains a form (which contains 2 input boxes
Language: PHP I have a form which asks users for their educational details, course
I have a post html form, and the action is index.php, which is the
I have a php form that has a known number of columns (ex. top
I currently have a PHP form that uses AJAX to connect to MySQL and
i have a PHP contact form that submits data, and an email...: <?php $dbh=mysql_connect
I have buy.php with a form where you enter items, quantity, shipping data, etc.
I have 3 pages: search.html. search.php, and edit.php I also have new.php which I

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.