PHP_Idiot Posted April 6, 2009 Share Posted April 6, 2009 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 More sharing options...
gevans Posted April 6, 2009 Share Posted April 6, 2009 you want to change this echo "<option value=$nt[VenueName]>$nt[VenueName]</option>"; to this echo "<option value=\"$nt[VenueName]\">$nt[VenueName]</option>"; You need to put quotes around values assigned to attributes in html Link to comment https://forums.phpfreaks.com/topic/152793-form-results-not-displaying-properly/#findComment-802360 Share on other sites More sharing options...
PHP_Idiot Posted April 6, 2009 Author Share Posted April 6, 2009 Gevans -your a genius Thanks for spotting that and pointing it out, I'm still very new to this and forgot about the quote marks. Anyway it works as it should now so thanks a lot. Link to comment https://forums.phpfreaks.com/topic/152793-form-results-not-displaying-properly/#findComment-802449 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.