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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:46:37+00:00 2026-05-23T18:46:37+00:00

I have a drop down list which is dynamically populated from a MySQL database

  • 0

I have a drop down list which is dynamically populated from a MySQL database :

<select name= "studentnames" >
<option value="0">Select a Student</option>

$RSStudentName = mysql_query( "SELECT StudentName, StudentID FROM Students " );

while($StudentNameList = mysql_fetch_object($RStudentName))
    {
    <option value = "<?php echo $StudentNameList->StudentID ;?> " >

    <?php 
        echo $StudentNameList->StudentName ;
     ?>
    </option>       
<?php 
    }
?>
</select>

The drop down gets filled these items as below :

Student1

Student2

Student3

Student4


Student Table is as :

SID | SNAME

S001 | Student1

S002 | Student2

S003 | Student3

Now when the users selects a student name from the drop down list, i want to get the value of that option , and insert it into a table. How to do this?

That is, if user selects Student3 in the drop down list, then i want to get S003 in some variable and insert it in a table? Please help with how to get the value attribute in a variable.

Could this be done?

$sid = $_POST('studentnames').value;
  • 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-23T18:46:38+00:00Added an answer on May 23, 2026 at 6:46 pm

    If it’s a simpel form post: the selected value will be in:

    $_POST['studentnames']
    

    In your code, use the ID as VALUE, and the name just as text

    <option value="[id field]">[studentname]</option>
    

    then

    $_POST['studentnames']
    

    will contain the is, might be better then naming it simply ‘student’…

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

Sidebar

Related Questions

i have a drop down list which is populated dynamically from database table i.e
I have a drop-down list which gathers data from the database and a textbox
Basically I have a drop down list which is populated with text and values
I have a drop-down list which causes a text-area to populate with different text
I have a drop down list displaying values in a select tag that I
I have a drop-down list containing classifications of currencies which can be instantiated as
I have a select list like such: <select name=taxonomy[1][] multiple=multiple class=form-select id=edit-taxonomy-1 size=7> <option
I have a drop down list (ddlFilterBuildings) which contains a list of buildings to
I have a web app where I need to change a drop down list
I've got a page which will have about ten drop down lists which are

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.