Grabbing the right record in a drop down from mysql
- by 86Stang
I'm using a form where the user can edit an entry. Everything is populating and all is well with the exception that I can't get the drop down to show the project that they've already assigned the image to.
$project_qry = "SELECT * from projects ORDER BY title ASC";
$project_res = mysql_query($project_qry);
$project_drop = "<select name=\"project_id\">\n";
while ($row = mysql_fetch_array($project_res))
{
if ($project_id == $row[title])
{
$project_drop .= "<option value=\"$row[id]\" selected>$row[title]</option>\n";
}
else
{
$project_drop .= "<option value=\"$row[id]\">$row[title]</option>\n";
}
}
$project_drop .= "</select>\n";
I'm sure it's something devilishly simple but I'm stumped.