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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:41:58+00:00 2026-06-01T17:41:58+00:00

There are two field in my form. 1) Html select field item ( From

  • 0

There are two field in my form.

1) Html select field item ( From mysql database)
2) Name box.

If a user select a item from html select tag and forgot to write his/her name then with php it’s say..

* Your username required

BUT then it’s doesn’t show the select item which user selected.. it’s show again Select… That’s why another error message appear..

* Please select your item.

How do i show this selected item with php?

Html form:

<tr>    
<td>Class</td>
<td>
<select class="td" name="class">
    <option selected="selected" value="">Select..</option>
    <?php
    include_once("../../toplevel/content/manage/dbcon/dbcon.php");
    $sql = mysql_query("SELECT * FROM class");
    while($re = mysql_fetch_array($sql))
    {
$re_class = mysql_real_escape_string(trim($re['c_name']));      
        echo "<option value='$re_class'> $re_class </option>";
    }
    ?>  
</select>
</td>
</tr>

<tr>
<td>Name</td>
<td><input type="text" value="<?php if(isset($_POST['uname'])) echo 
$_POST['uname']; ?>" name="uname" class="td" /></td>
</tr>
<tr>

I can do this for Name filed But how do i do this for the select field ?
Thanks a lot.
Shibbir

  • 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-01T17:41:59+00:00Added an answer on June 1, 2026 at 5:41 pm
        <tr>    
        <td>Class</td>
        <td>
        <select class="td" name="class">
            <option value="">Select..</option>
            <?php
            include_once("../../toplevel/content/manage/dbcon/dbcon.php");
            $sql = mysql_query("SELECT * FROM class");
            while($re = mysql_fetch_array($sql))
            {
               $re_class = mysql_real_escape_string(trim($re['c_name'])); 
               $sel='';
               if($re_class==$_POST['class'])  {
                 $sel='selected="selected"';
               }   
                echo "<option value='$re_class' ".$sel."> $re_class </option>";
            }
            ?>  
        </select>
        </td>
        </tr>
    
        <tr>
        <td>Name</td>
        <td><input type="text" value="<?php if(isset($_POST['uname'])) echo 
        $_POST['uname']; ?>" name="uname" class="td" /></td>
        </tr>
        <tr>
    

    Did u mean this?

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

Sidebar

Related Questions

I have a mysql database with two tables: table1 (id, name, emailid) table2 (id,
I need a HTML-based form to tie database records together. The user scenario that
To sum it up, there are two basic trains of thought: The private field
There are two classes: A and B . There are algorithms for converting from
Is there a way to submit an HTML form using JavaScript that is guaranteed
I am developing a dynamic form based on user selection. It is a two-staged
I have two issues When I submit the character ' through my HTML form
I have a form with a table that has two input boxes, a select
I've got a standard HTML form, which is split into two sections using fieldset
I've a simple html form with text field with id=zip what I want to

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.