Filling a Drop down box with an ID in the table?
Posted: Sun Mar 13, 2005 10:49 am
Hi,
Im having a really frustrating problem! I have to admit im new to PHP and dont know exactly what im doing yet but i was wondering if someone could help me with the following problem.
I am trying to build a site as a project which is similar to imdb.com with a loggen in user to be able to review and browse movies in a mysql database. However im only really at the begining stages of all this and i am currently having a problem with the page i am using to input data into the database tables with. The page has all the usual, MovieID, MovieName, Runtime ect.. but also two enum rows, Genre and Certificate. I am having trouble populating the drop down box containing these values, currently it just loads up empty.
This is the code i am using;
As you can see it should be selecting an ID but of course there isnt one in my table for the genre as the ID is given to the movie ID. So is there a more simple way of achieving this without the ID? Or do i need to make seperate tables for the Genre and Certificate Rows?
I would be very greatful for any help you could provide,
Regards,
Alex
feyd | Please use
Im having a really frustrating problem! I have to admit im new to PHP and dont know exactly what im doing yet but i was wondering if someone could help me with the following problem.
I am trying to build a site as a project which is similar to imdb.com with a loggen in user to be able to review and browse movies in a mysql database. However im only really at the begining stages of all this and i am currently having a problem with the page i am using to input data into the database tables with. The page has all the usual, MovieID, MovieName, Runtime ect.. but also two enum rows, Genre and Certificate. I am having trouble populating the drop down box containing these values, currently it just loads up empty.
This is the code i am using;
Code: Select all
<tr>
<td bgcolor="#FFFFFF">Movie Genre</td>
<td bgcolor="#FFFFFF">
<select name="movie_genre">
<option value="" selected>Select a genre for the film...</option>
<?php
$sql = "SELECT (possible ID??), Genre " .
"FROM Movie ";
$result = mysql_query($sql)
or die("<font color=\"#FF0000\">Query Error</font>" .
mysql_error());
while ($row = mysql_fetch_array($result)) {
if ($row['Genre'] == $movie_type) {
$selected = " selected";
} else {
$selected = "";
}
echo '<option value="' . $row['(PossibleID??)'] . '"' .
$selected.'>' . $row['Genre'] . '</option>' .
"\r\n";
}
?>
</select>
</td>
</tr>I would be very greatful for any help you could provide,
Regards,
Alex
feyd | Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]