Code:
create table model_in_city
( model_id int unsigned not null,
city_id int unsigned not null,
city_display tinyint(2) unsigned,
primary key (model_id, city_display)
);
city_id = the id of the city. They are displayed in this table by number.. eg 44 = Toronto, etc
city_display = their city choice.. models can choose up to 4 cities to be displayed in. In this example i'm trying to get city_display = 1 to work first.
Here's what I have now but don't know to to incorporate the selected value into the form:
Code:
<?php
include("../includes/connect.php");
$id = 17;
$query = "SELECT city.*, model_in_city.* FROM city, model_in_city WHERE model_in_city.model_id = $id AND model_in_city.city_display = 1";
if ($result = $db->query($query))
{
echo "<select name=\"select\">";
while ($row = $result->fetch_assoc())
{
$name = $row['city_name'];
$city_id = $row['city_id'];
echo "<option>$name</option>";
}
echo "</select>";
echo "$city_id"; // just making sure the correct value is being fetched.
$result->free();
}
$db->close();
?>