Display data from mysql into combobox in PHP

For very beginners It is not easier to display data from required mysql table into combobox in PHP. Again after call any javascript function from that control’s onClick which will submit the page, always display only first or last data into combobox as well as it takes same value as input which bother developers. So in php there is easier way to handle such a problem. I have a table named casa_session from where I have to display session_title into select field. The codes are follows:

<? include(“connection.php”) ?>

<TR HEIGHT=”25″>
<TD colspan=”2″>Semester</TD>
<select name=”salSemesterID” onClick=”submitCboSemester();”>
$query_disp=”SELECT * FROM casa_semester order by semester_id asc”;
$result_disp = mysql_query($query_disp, $conn);
while($query_data = mysql_fetch_array($result_disp))
<option value=”<? echo $query_data[‘semester_id’]; ?>”<?php if ($query_data[‘semester_id’]==$_POST[‘salSemesterID’]) {?>selected<? } ?>><? echo $query_data[‘name’]; ?></option>
<? } ?>

Now it works fine.


9 Responses

  1. Thanks mate. Keep up the good work

  2. There are two page one is contain html information and other page contain php information .Now how i show the dqatabase data to html information page combo box

  3. thank you dude……… u made my day by sharing this

    thanks again

  4. Thanx guys it was really cool
    thanx a loyt for helping me out to do the coding for a combobox.

  5. hi..
    actually im very new to php and im getting problem in making some code,
    I want to make an application which contain Teachers and classes…
    if v select teacher throw combo box it should generate all the classes to which this particular teacher will teach.similarly for class………
    can u giv some idea to make code for this!!
    waiting for ur reply
    thank u……………..

  6. please show me how to show table record database with combobox selected…. thx

  7. i have mysql table like…


    i have a combo box that show from mysql data field id.
    i want to do now when i click id 1 textbox1 will show customer name and another text will show amt.
    any one hepl me how can i coding in php

  8. Thanks

  9. hay i m new in php plz help me how can edit and update combo box

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: