I have 2 files. "index.php" and "output.php". Inside index.php I have a dropdown-list containing all Italian cities that was obtained from mysql table. Scope of my test is to select a city from dropdown-list and send value to output.php that print the value.
this is my code:
-index.php:
<form action="output.php" method="post">
<div align="center">
<?php
echo "Questa è una prova";
// Open db connection
$con = mysqli_connect ( "127.0.0.1", "root", "", "test" );
// Check connection
if (mysqli_connect_errno ( $con )) {
echo "Failed to connect to MySQL: " . mysqli_connect_error ();
}
echo "</br>";
echo "</br>";
echo "</br>";
//Query principale
$result = mysqli_query ( $con, "SELECT * FROM it_cities" );
?>
<select name="fcity">
<?php
while($row = mysqli_fetch_array($result))
{
echo '<option value=' . $row['comuni'] . '>' . $row['comuni'] . '</option>';
echo "<br>";
}
?>
</select>
</br>
<input type="submit" value="Invia">
</div>
</form>
-output.php:
<?php
$city= $_REQUEST ['fcity'] ;
echo "$city" ;
?>
My problem is with strings containing space (example "Abano Terme", only "Abano" is printed on the screen).
Thanks