Please Login or Register to continue.


Hello, How to add a Combobox inside the HTML form for subject bio, chemistry, eng, etc..

I wrote every code from technomaster.com site. What I make changes in insert or display code to make it possible to enter Combobox.

My HTML form and table. All data are coming from a MySQL database table using MySQL query and PHP code. 

How can I add Combobox in HTML form and select, display, insert data into the database using PHP? 

(90 Points)
in PHP


4 Answers
(9.3K Points)

I am not getting your point. Where you want to add Combobox. You can add the select option for all subjects like this - 

<select name="name">
  <option value="A">item1</option>
  <option value="B">item2</option>
  <option value="n">item_n</option> 

Select all subjects and display them in the list. 

<select name="subject">
  <option value="">your PHP code </option>

Change the subject variable according to your created variable for the subject. 


I Want to add a Combobox for subjects. For Example:- When I Insert new Subject & TotalMarks through another HTML form , the Subjects should come into the combobox.
osama 05 Sep 2019
Check my other answer.
shakti 05 Sep 2019

(7.3K Points)

Thank you for asking this question here. I am glad to solve your problem. You can add a checkbox as the subject input box. 

 echo "<input type='checkbox' name='sujects' value='".$row['subjects']."<br />";

Use select query and display the data inside the checkbox. It will help you insert data using the name subject. 

Comment me if the problem occurs.


(4.3K Points)

Add Combobox in PHP. 

Try this code. It will help you to add Combobox to your website HTML form.

$result = mysql_query($mysqli,"SELECT students FROM table_name") or die(mysql_error());
if (mysql_num_rows($result)!=0)

echo '<select name="drop_2" id="drop_2">
      <option value=" " selected="selected">Choose one</option>';
   while($drop_2 = mysql_fetch_array( $result ))
  echo '<option value="'.$drop_2['students'].'">'.$drop_2['students'].'</option>';
echo '</select>';

Change table name and column name. 


(9.3K Points)

I solved your problem. You can add Combobox like this. 

combobox in php


Follow the steps - 

1. Add this code at the subject input place.

$cser=mysqli_connect("localhost","root","","test") or die("connection failed:".mysqli_error());
$result = mysqli_query($cser,"SELECT pname FROM crud2") or die(mysql_error());
if (mysqli_num_rows($result)!=0)
echo 'Product Name : <select name="pname">
      <option value=" " selected="selected">Choose one</option>';
   while($drop_2 = mysqli_fetch_array( $result ))
  echo '<option value="'.$drop_2['pname'].'">'.$drop_2['pname'].'</option>';
echo '</select>';

2. Now change the test database to, your database or add your config file. 

2. Change the crud2 table name to your table name. 

3. Change pname to the students' column name. 

In this way, you can add Combobox in your website HTML form using PHP and Mysql database tables.

Benefits - 

1. Select data and display it in Combobox.

2. Insert data using select name="pname" . Change pname according to your column name.  

Check my answer on the new question.
shakti 06 Sep 2019

Related Questions :-

Featured Items:-

Certificate system in PHP website | PHP scripts


Home Credito loan finance management multipurpose system in PHP


Result management system with Marksheet in PHP website | PHP Scripts


Your Answer

You can post your answer after login..