Im trying to get a dynamic list in a form. I do this by doing a query to the database and i get the name and the ID. This is what i get displayed:

Now, when i send the form, im recieving the NAME of the department. However i want to get the id only. This is my code:
Code: Select all
<?
//DB conection
mysql_connect("localhost","adjusted_reloj","xxxxx");
//SQL command
$sSQL="Select id_dept, nombre From department Order By nombre";
$result=mysql_db_query("adjusted_reloj",$sSQL);
echo "<select name = id_dept>";
//Show the drop down list
while ($row=mysql_fetch_array($result))
{echo '<option>'.$row["nombre"];}
mysql_free_result($result)
?>
Code: Select all
echo '<option>'.$row["nombre"];Code: Select all
echo '<option>'.$row["id_dept"];I've thought of sending both the ID and the department name, but im not sure how to "cut" the department name afterwards so i get only the id.
any suggestions are very welcome, thanks!
also, im not quite sure what im acomplishing with echo "<select name = id_dept>"; but if i remove it my drop down list is blank.