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

  • Home
  • SEARCH
  • 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 3692416
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:15:35+00:00 2026-05-19T04:15:35+00:00

I want to write a code that should let me select from a drop

  • 0

I want to write a code that should let me select from a drop down list and onClick of a button load the data from a mysql database.However I cannot access the value selected in the drop down menu.I have tried to access them by $_POST['var_name'] but still can’t do it.

I’m new to PHP.

Following is my code:

 <?php

      function load(){
       $department = $_POST['dept'];
       $employee = $_POST['emp'];

       //echo "$department";
       //echo "$employee";

       $con = mysqli_connect("localhost", "root", "pwd", "payroll");
       $rs = $con->query("select * from dept where deptno='$department'");
       $row = $rs->fetch_row();
       $n = $row[0];
       $rs->free();
       $con->close();
      }

 ?>
    <html>
     <head>
      <title>Payroll</title>
     </head>

     <body>
      <h1 align="center">IIT Department</h1>
      <form method="post">
      <table align="center">
       <tr>
        <td>
          Dept Number: 
          <select name="dept">
               <option value="10" selected="selected">10</option>
               <option value="20">20</option>
               <option value="30">30</option>
               <option value="40">40</option>
          </select>


            </td>

        <td>
             <input type="button" value="ShowDeptEmp" name="btn1">        
        </td>
        <td>
          Job: 
          <select name="job">
               <option value="President" selected="selected">President</option>
               <option value="Manager">Manager</option>
               <option value="Clerk">Clerk</option>
               <option value="Salesman">Salesman</option>
               <option value="Analyst">Analyst</option>
          </select>
        </td>
        <td>
             <input type="button" value="ShowJobEmp" name="btn1">
        </td>
       </tr>
      </table>
      </form>
        <?php if(isset($_POST['dept']) && $_POST['dept'] != "") load();  ?>        
     </body>
    </html>
  • 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-19T04:15:36+00:00Added an answer on May 19, 2026 at 4:15 am

    change button to submit

     <input type="submit" value="ShowDeptEmp" name="btn1">
    

    and

     <input type="submit" value="ShowJobEmp" name="btn2">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's suppose that I have a list of elements, and I want to select
I want to write a php code that can search for multiple keywords separated
I want to write a java code that executes some Linux command: String cmd
I want to write a parallel code that works on a 3D matrix where
I want to write a line of code that returns a pointer to this
this is my code that I write it but I want to use LINQ
I have third-party C code that writes data to a file. I want to
I want to write a Parser that produces some data structure and validates its
Let's say that you want to write an application that processes multiple text files,
I want write a little code analyzer which parses nested structures and translates into

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.