I am trying to pull data from a table to fill a drop down list. Now, i got the fill part working, but am having an issue passing a variable value to my form post action.

Code:

$query ="SELECT UniqueIdentifier, LastName, FirstName
FROM BrokerMain
ORDER BY LastName";
$result = @mssql_query($query);

echo "<select name='test'><option value='default'>Choose a Broker:</option>";
while ($row=mssql_fetch_array($result))
{
$uid=$row;
$ln=$row;
$fn=$row;
$spacer= ", ";
echo "<option value='$uid'>" . $ln . $spacer . $fn . "</option>";
}
echo "</select>";
echo "<form action='editbroker.php?UniqueIdentifier=$uid' method='post'><td valign='top'><input type='submit' name='edit' value='Edit'/></form>";

End Code


The button is there, but the value of $uid is not being passed based on the user selected in the drop down box. Any ideas?

Makr sure that the field name 'UniqueIdentifier' is correct. Anyway, what is the type of this 'UniqueIdentifier' field ?
Try with this:

echo "<option value='" . $uid . "'>" . $ln . $spacer . $fn . "</option>";

Instead of:

echo "<option value='$uid'>" . $ln . $spacer . $fn . "</option>";

made the change, still no luck. I am positive that the field name UniqueIdentifier is correct. if i take the form line and put it in the while loop, the query works, i get a submit button for each record in the drop down and it grabs the $uid value and passes it to the next page. only issue is, i have 900 submit buttons. i need just one, that changes the value based on who i chose in the drop down list.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.