I can call the values of the drop down box from the database, but I can’t save the selected value in a new row within the database. Can someone please tell me where I’m going wrong?
if (isset($_POST["addDestination"]) && $_POST["addDestination"]=="yes")
{
$countriesName=$_POST["countriesName"];
$Name=$_POST["Name"];
$photo=$_POST["photo"];
$description=$_POST["description"];
$Airport=$_POST["Airport"];
$Airport2=$_POST["Airport2"];
$Airline=$_POST["Airline"];
$Airline2=$_POST["Airline2"];
$Airline3=$_POST["Airline3"];
$Airline4=$_POST["Airline4"];
$dbQuery= "INSERT INTO destinations VALUES( NULL, '$countriesName', '$Name', '$photo', '$description', '$Airport', '$Airport2', '$Airline', '$Airline2', '$Airline3', '$Airline4')";
$result= mysql_query($dbQuery,$db);
The html code and php code that call the values in from the database is:
<form id="addDestination" name="addDestination" method="post" action="addDestination.php">
<input type="hidden" name="addDestination" value="yes">
<div id="countriesName" class="info"><span class="formLabel">Country (Please select one of the following)</span><br>
<?php
echo "<p></p>";
$dbQuery="SELECT Name FROM countries order by name asc";
$dbResult=mysql_query($dbQuery);
echo "<select name=\"Name\">";
while ($dbRow=mysql_fetch_array($dbResult)) {
$Name=$dbRow["Name"];
echo "<option value='$Name'>$Name</option>";
}
echo "</select>";
echo "<p> </p>";
?>
</div>
When I try to save a selected value, the field in the database stays blank.
I think this might be that rather than:
you may need to use:
"Name"is the name of your actual HTML select, rather than"countriesName"which is the containing div.