Jump to content

Form Results not displaying properly


PHP_Idiot

Recommended Posts

Hi I have a simple web form that I using to collect info, and the the following php t display it:

<?php

if ($_POST['Day'] == '')
{
  $Day = '<span style="color:red;">Date omitted.</span>';
}
else
{
  $Day = $_POST['Day'];
}

if ($_POST['Month'] == '')
{
  $Month = '<span style="color:red;">Month omitted.</span>';
}
else
{
  $Month = $_POST['Month'];
}
  
if ($_POST['Year'] == '')
{
  $Year = '<span style="color:red;">Year omitted.</span>';
}
else
{
  $Year = $_POST['Year'];
}

if ($_POST['Venue'] == '')
{
  $Venue = '<span style="color:red;">Venue omitted.</span>';
}
else
{
  $Venue = $_POST['Venue'];
}
?>
<html>
<head>
<title>Process Employee</title>
</head>
<body>
<h1>Game Details</h1>
<ul>
<?php
//Output the variables as list items.
  echo "<li><b>Venue:</b> $Venue</li>";
  echo "<li><b>Tournament Date:</b> $Day / $Month / $Year</li>";
?>
</ul>
</body>
</html>

 

The date displays perfectly (1 / Jan / 2009) but the Venue only displays the first word in each name, eg Bar, The.

It stops at the space between words!

 

The list of venue names appears in a dropdown list generated from a mySQL db. generated by this code:

$query="SELECT VenueName FROM Venue ORDER BY VenueName";

$result = mysql_query ($query);
echo "<select name='Venue' id='Venue' value=''>Venue Name</option>";
// printing the list box select command

while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
echo "<option value=$nt[VenueName]>$nt[VenueName]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box 

?>

Once the form is complete a submit button is pressed and the above php comes into play.

 

Should I be saving all the venue names in the DB with underscores instead of spaces! eg The_Pub?

Or is there a way to get it to ignor the spaces?

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/152793-form-results-not-displaying-properly/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.