Hi, I'm new to this forum and PHP in general. This code is for an admin editing page that I'm working on. What I'm trying to do is have the dropdown box fill out from game_categories table, and have the option that has been set in games table to be selected.
<?php
echo '<p><a id="rows2">Games Select:</a><select name="game_cat_id" id="game_cat_id"><option value="">Select a Game</option>';
$serverQuery = "SELECT c.game_cat_id AS gameCat_id, c.game_category FROM game_categories AS c";
$serverCompareQuery = "SELECT game_cat_id , game_id FROM games AS g WHERE game_id=$id";
$serverCompareResult = @mysql_query ($serverCompareQuery);
$serverResult = @mysql_query ($serverQuery);
while ($serverRows = mysql_fetch_array($serverResult, MYSQL_ASSOC)) {
$compareRows = mysql_fetch_array($serverCompareResult, MYSQL_ASSOC);
echo '<option ';
if($compareRows['game_cat_id'] == $serverRows['gameCat_id']) {
echo 'selected="selected"';
} else {
echo '';
}
echo ' value=' . $serverRows['gameCat_id'] . '>' . $serverRows['game_category'] . '</option>\n';
}
echo '</select></p>';
?>