Reputation: 13
I have a drop down list with Select Option and information written inside are retrieved from the database with a query .
<select name="moto">
<?php
include 'connessione.php';
$qry = "SELECT NomeOggetto FROM Oggetto";
$result = mysql_query($qry);
while($row = mysql_fetch_array($result))
{
echo '<option value='.$row["NomeOggetto"].'>'.$row["NomeOggetto"].'</option>';
}
?>
</select>
The problem is that if in the menu i have the name of a motorbike with one space between its name , for example ( Kawasaki Ninja) , when i send it to the PHP page with the POST Method it only displays Kawasaki . How can i show the entire name with the space included ? this is the php page :
<?php echo $_POST['moto']; ?>
Upvotes: 1
Views: 131
Reputation: 10060
Try to send it with urlencode and decode it.
You can also print it as echo " '$_POST['moto']' "
will print word1 word2
as 1 string because it is wrapped in quotes:
Try to print_r($_POST);
and see if you're posting the entire string.
Upvotes: 0
Reputation: 4043
You have to put quotes around your attribute values in your HTML
from
echo '<option value='.$row["NomeOggetto"].'>'.$row["NomeOggetto"].'</option>';
to
echo '<option value="'.$row["NomeOggetto"].'">'.$row["NomeOggetto"].'</option>';
Upvotes: 3