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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:40:41+00:00 2026-05-23T17:40:41+00:00

I am trying to use a dynamic select form to send information to a

  • 0

I am trying to use a dynamic select form to send information to a MySQL database. The user will be able to choose their school, and then select their major from within that school’s list (all retrieved from a MySQL table). I then want to send that information to a different table in the database to be stored.

This is what I have for the code thus far:

<select name="school">
  <php
  $sql = "SELECT school_name, school_id FROM school_table ORDER BY school_name";
  $query = mysql_query($sql,$conn);

  while($row = mysql_fetch_array($states))
    {
  echo ("<option value=$row[school_id]>$row[school_name]</option>");        
    }
  ?>
</select>

I don’t know how to make the second select, which would ideally recognize the school_id from the first table and match it with the corresponding school_id on the second table, which also lists the majors at that school. Also, I don’t know how to send the form when it is finally done to a MySQL table.

  • 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-23T17:40:42+00:00Added an answer on May 23, 2026 at 5:40 pm

    You could either use a simple form to submit the value from the combobox to the server (as HTTP POST or HTTP GET) and use the value as a variable in you SQL statement or you could use a simple AJAX request to send the necessary information to your php script. Anyway, your serverside code should look like this:

    //process.php
    $myRetrievedValue = $_POST["school"];
    $mySqlStm = "SELECT * FROM foo WHERE bar = '".mysql_escape_string($myRetrivedValue)."'";
    

    On the client side you code could look like this (using a simple form and no AJAX stuff):

    <form action="process.php" method="post">
    <select name="school">  
    <php  $sql = "SELECT school_name, school_id FROM school_table ORDER BY school_name";  
          $query = mysql_query($sql,$conn);  while($row = mysql_fetch_array($states))    {  
          echo ("<option value=$row[school_id]>$row[school_name]</option>");            }  ?>
    </select>
    <input name="" type="submit" />
    </form>
    

    Please remember: Whenever you use a user input in you query use prepared statements (or at least escape methods as above) to avoid SQL injections.

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

Sidebar

Related Questions

I'm trying to use jQuery validation for a dynamic form I'm setting up. In
I am trying to use the ASP.NET Dynamic Data features to generate CRUD scaffolding
I trying to use ImageInfo and Jython to get information from a image on
I'm trying to create a dynamic select box in JavaScript with a range of
I am trying to use a strong ref cur with dynamic sql statment but
Using LINQ , I've been trying to use the System.Linq.Dynamic library in order to
Trying to use an excpetion class which could provide location reference for XML parsing,
Trying to use a guid as a resource id in a rest url but
While trying to use LINQ to SQL I encountered several problems. I have table
I' trying to use a Linq query to find and set the selected value

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.