I have one table named as movie. which contains fields like movie_id, movie_name etc.
I want that movie_id in my drop down list. so i have to retrive that data from movie table. I tried my best but i dont get success in this. plz help me to retrive data in my drop down list from movie table.

4 Years
Discussion Span
Last Post by rpv_sen

Where do you get stuck? The principle is: construct appropriate query to retrieve rows from the table and then use data of each row to build option elements:

// query
$q = 'SELECT id, title FROM movies';

// connection and querrying stuff

// start the html code for select element (drop down)
echo '<select name="movies">';

// add options from the database (mysql used here)
while($row = fetch_assoc($mysql_result)) {

    echo '<option value="' . $row['id'] . '">' . $row['title'] . '</option>';

// end the html code for select element
echo '</select>';

Post the code you have so far.

Edited by broj1


Thank u so much. And can u plz guide me how related combo boxes can work? I want to do as:
I am going to design quick booking page in php. in that I want to do that user will select city name from my 1st combo box. city name comes from my location table then another combo box should find the theatre_name from table where city_name= selected city. and fetched data should be displayed in that combo box. Like wise same procedure should be follow for movie_name, show_time etc.

location table contains fields like theatre_id, theatre_name, owner_name,address, city, email_id etc

movie tbale contains movie_id, movie_name, release_date, actors, acress, director etc.

theatre table contains theatre_id,theatre_name, no_of_screen

So plz help me in this.
Thanks to u a lot in advance

<select name="select1">
<option value="Select Option">Select Option</option>
$result=mysql_query("select * from tablename");
<option value="<?php echo $row['row_name1']; ?>" <?php echo $row['row_name'];?></option>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.