PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I'm making some assumptions on your tables, but you need to get all genres for the movie, you were only getting one. Then see if the current genre is in that list. Something like this:
$select = "SELECT * FROM genres WHERE MovieID = '$id'";
$result = mysql_query($select);
while ($row = mysql_fetch_array($result)) {
$movie_genres[] = $row['GenreTypeID'];
}
$query = "SELECT * FROM genretypes ORDER BY Genre ASC";
$result2 = mysql_query($query);
while ($genre = mysql_fetch_array($result2)) {
$selected = "";
if (in_array($genre['GenreTypeID'], $movie_genres)) {
$selected = "selected=\"selected\"";
}
echo "<option $selected value=\"" . $genre['GenreTypeID'] . "\">" . $genre['Genre'] . "</option>";
}
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.