How to diplay value selected in drop down list
Posted: Sun Jul 04, 2010 7:11 am
I have a mysql database called 'places' containing these fields:
country | place | lon |lat | id
Netherlands | Cadzand | 3.4167 |51.3667| 1
Netherlands | Oostburg | 3.4167 |51.3667| 2
Netherlands | Terneuzen | 3.4167 |51.3667| 3
I want to make a script for selecting a place in a drop down list.
After hitting the submit button the selected place has to be displayed.
But there's my problem. It doesn't display anything at all.
Who has a clue?
My script:
<form action='<?=$_SERVER['php_self']?>' method="post">
<?php
$result = mysql_query("select id, place, lat, lon FROM places");
print "<p>Select a place:\n";
print "<select name=\"id\">\n";
while ($row = mysql_fetch_assoc($result)){
$id = $row['id'];
$place = $row['place'];
print "<option value=$id>$place\n";
}
print "</select>\n";
?>
<input type="submit" name="SUBMIT" value="Submit">
<br>
<?php
echo "You have choosen " . $_POST['place'];
?>
country | place | lon |lat | id
Netherlands | Cadzand | 3.4167 |51.3667| 1
Netherlands | Oostburg | 3.4167 |51.3667| 2
Netherlands | Terneuzen | 3.4167 |51.3667| 3
I want to make a script for selecting a place in a drop down list.
After hitting the submit button the selected place has to be displayed.
But there's my problem. It doesn't display anything at all.
Who has a clue?
My script:
<form action='<?=$_SERVER['php_self']?>' method="post">
<?php
$result = mysql_query("select id, place, lat, lon FROM places");
print "<p>Select a place:\n";
print "<select name=\"id\">\n";
while ($row = mysql_fetch_assoc($result)){
$id = $row['id'];
$place = $row['place'];
print "<option value=$id>$place\n";
}
print "</select>\n";
?>
<input type="submit" name="SUBMIT" value="Submit">
<br>
<?php
echo "You have choosen " . $_POST['place'];
?>