david.moody
01-18-2012, 09:11 AM
Hello,
I have a database with a table containing names (for example "Mr Joe Blogs" could be one of the entries.)
On a page I have a form with a dropdown box populated from this table, which displays correctly. However, when I click submit only "Mr" is saved to the new entry in a different table. Here's my dropdown box code:
$query = "SELECT * FROM teachers";
$result = mysql_query($query) or die(mysql_error());
echo "<select name=teacher>";
while ($db_field = mysql_fetch_assoc($result)) {
$temp = nl2br($db_field["Name"]);
echo "<option value=" . $temp . ">" . $temp . "</tr>";
}
echo "</select>";
In the code for collecting the information from the form and sending it to the database I have this line:
$teacher = $_POST['teacher'];
If I print $teacher to the screen this error shows up, but it does't show up in $temp or nl2br($db_field["Name"]) if I were to use it directly.
Any clues why everything after the space is lost when I hit the submit button?
David.
I have a database with a table containing names (for example "Mr Joe Blogs" could be one of the entries.)
On a page I have a form with a dropdown box populated from this table, which displays correctly. However, when I click submit only "Mr" is saved to the new entry in a different table. Here's my dropdown box code:
$query = "SELECT * FROM teachers";
$result = mysql_query($query) or die(mysql_error());
echo "<select name=teacher>";
while ($db_field = mysql_fetch_assoc($result)) {
$temp = nl2br($db_field["Name"]);
echo "<option value=" . $temp . ">" . $temp . "</tr>";
}
echo "</select>";
In the code for collecting the information from the form and sending it to the database I have this line:
$teacher = $_POST['teacher'];
If I print $teacher to the screen this error shows up, but it does't show up in $temp or nl2br($db_field["Name"]) if I were to use it directly.
Any clues why everything after the space is lost when I hit the submit button?
David.