We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,389 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

fetch result in my drop down list

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.

5
Contributors
6
Replies
1 Week
Discussion Span
8 Months Ago
Last Updated
10
Views
MMadhavi
Newbie Poster
17 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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.

broj1
Nearly a Posting Virtuoso
1,212 posts since Jan 2011
Reputation Points: 167
Solved Threads: 164
Skill Endorsements: 13

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

MMadhavi
Newbie Poster
17 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
pritaeas
Posting Prodigy
Moderator
9,315 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,466
Skill Endorsements: 86
<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> 
rajilakshmi
Newbie Poster
18 posts since Jul 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Use inner join query to fetch the data

rajilakshmi
Newbie Poster
18 posts since Jul 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0
rpv_sen
Posting Whiz in Training
204 posts since Mar 2011
Reputation Points: 24
Solved Threads: 18
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.1283 seconds using 2.66MB