Page 1 of 1

Form input text value from database row not working

Posted: Sun Oct 22, 2006 9:15 pm
by waradmin
I am trying to display a row from a database as the value of a text box, but it is cutting it off at the first space.

For example the database row will be: University of Minnesota Duluth but it will only display University in the text box. Any way to fix this to display everything and not stop after a space?

Posted: Sun Oct 22, 2006 9:26 pm
by Cameri
First, check if in the db the string is complete.
Secondly, I'll be glad to help you if you showed the part of your code where the problem is.

Posted: Sun Oct 22, 2006 10:54 pm
by John Cartwright
sounds like you forgot quotes around the value attribute

Posted: Mon Oct 23, 2006 8:00 am
by waradmin

Code: Select all

echo "<tr><td><div align=right>College:</div></td><td><input type=text name=college value=" . $row['college'] . "><input type=text name=hsyear maxlength=4 size=4 value=" . $row['college_grad_year'] . "></td></tr>";
Where $row['college'] is stored in the database as TEXT: University of Minnesota Duluth

Cuts it off at University, but when just echoing the row it will output the whole thing.

Posted: Mon Oct 23, 2006 8:06 am
by Mordred
As Jcart said, you forgot putting quotes. Those quotes are in the PHP source, there are no quotes in the HTML. View source of the result page.

Posted: Mon Oct 23, 2006 8:07 am
by Rovas
http://www.php.net/manual/en/function.substr.php read it and you will figured it out.

Posted: Mon Oct 23, 2006 8:24 am
by waradmin
sorry about that, I didnt even realize I forgot \" on the value, bah.