I would like to create a drop down list that will reflect values stored in a MySQL database. The table is a user table that has an id, firstname and last name fields. I would like the dropdown list to reflect all the id values from the table and a text box should output the respective first name and last name. I have created a drop down list which I am able to see all the values of the id field but the text box only reflects the name of the last value of the table. Could some one help me with this problem?
See snippet of code below:
//code starts
<?php
include("db.php");
echo "<select name=\"mid\">\n";
echo "<option value=\"\">Select Value</option>\n";
$strQuery=("SELECT * FROM member ORDER BY memberid ASC");
$rsrcResult = mysql_query($strQuery);
while($row = mysql_fetch_assoc($rsrcResult)) {
$strA = $row["id"];
$strB = $row["memberid"];
$fname=$row["firstname"];
$lname=$row["lastname"];
echo "<option value=\"$strA\">$strB</option>\n";
}
echo "</select>";
echo "<input type=\"text\" name=\"firstname\" value=\"".$fname." ".$lname."\" />";
?>
//code ends
I am able to see all the member ids but the textbox only reflects the first name and lastname of the last entry in the table. Could anyone shed some light on this please? Thanks