Forum Moderators: coopster

Message Too Old, No Replies

Posting from dynamic drop down list

Posting to mysql database

         

malcolmcroucher

11:30 am on Jan 13, 2008 (gmt 0)

10+ Year Member



Hiya ,

I am trying to do the following : select a country from a dynamic drop down list and then add a province to that country and post the countrycode for that province with the province . The problem is i get a blank country code. Any suggestions would be very thankful for.

The variable i am posting for country code is $id.

Province1.php

<?
Include ("connect.php");

$sql="select * from Country";
$result=mysql_query($sql);

while ($row=mysql_fetch_array($result)) {

$id=$row["Countrycode"];
$thing=$row["Country"];
$options.="<OPTION VALUE=\"$id\">".$thing;

}
?>
<form name ="input" action="Process_province.php" method="post">
<SELECT NAME=thing>
<OPTION VALUE=0>Choose
<?=$options?>
</SELECT>

<td>Province:</td><td> <input class="input" type="text" name="province"/></td>
<input type="submit" value="submit"><br>
</form>

</Body>
</html>

Process_province.php

<?
Include ("connect.php");

$province=$_POST[province];
$Id=$_Post[Id];

$sql="INSERT INTO province (Provincecode,Province,Countrycode) Values ('','$province','$id')";

if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added" ;

?>
</div>

RonPK

11:35 am on Jan 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hiya,

The name of your country selectbox is 'thing'. That will be the name of the POST element holding the country ID.