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.

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.

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>
<?php
$result=mysql_query("select * from tablename");
while($row=mysql_fetch_array($result))
{
?>
<option value="<?php echo $row['row_name1']; ?>" <?php echo $row['row_name'];?></option>
<?php                                                
}   
?>  
</select> 

Use inner join query to fetch the data

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.