I have a select dropdown that is being populated and displayed correctly from a mysql query:
<select name="title">
<option></option>
<?php
while($row = mysql_fetch_assoc($title_data)) {
echo '<option value=' . $row["title"];
echo '>' . $row["title"];
echo '</option>';
}
?>
</select>
When I add code to check which row was selected, I get an undefined index error for each row in the query results:
<select name="title">
<option></option>
<?php
while($row = mysql_fetch_assoc($title_data)) {
echo '<option value=' . $row["title"];
if($_POST["title"] == $row["title"]) {
echo ' selected';
}
echo '>' . $row["title"];
echo '</option>';
}
?>
</select>
I'm realtively new to this and may be missing something obvious. I had checked the posts and did not see this particular example where I am using a while loop from a query and trying to echo the selected attribute. The actual error text is inserted into the dropdown box:
Notice: Undefined index: title in C:\xampp\htdocs\indexdb.php on line 215 >Analyst I" and appears for each row in the dropdown box.
I apologize if this has been covered as I stated, this is my first php code and is a protype only. This is the only hurdle I have not been able to overcome.