So I am creating some php code for the add accommodation section of my website. The user is given the option of selecting a city from the drop down menu (the list is retrieved from the city table in the mysql database by using a simple query and echo). But what needs to be stored in the add accomodation table is the city ID and of course I can't be asking the user for that! What I can't figure out is how to query the city table using the selected city and retrieve the city ID from the same table and store that in the accommodation table in the backend database. Here is the code I have so far.
<?php
$query = "SELECT City_Name FROM Cities";
$result = mysql_query($query);
?>
<p>
<label for = "City_Name" class = "fixed_required">City: </label>
<select name="select_City" id="select_City" value="<?php if(isset($_POST['City_Name'])) echo $_POST['City_Name']; ?>"/>
</p>
<?php
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
?>
<option value="<?php echo $line['City_Name'];?>"> <?php echo $line['City_Name'];?> </option>
<?php