Form input text value from database row not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
waradmin
Forum Contributor
Posts: 240
Joined: Fri Nov 04, 2005 2:57 pm

Form input text value from database row not working

Post 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?
User avatar
Cameri
Forum Commoner
Posts: 87
Joined: Tue Apr 12, 2005 4:12 pm
Location: Santo Domingo, Dominican Republic

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

sounds like you forgot quotes around the value attribute
User avatar
waradmin
Forum Contributor
Posts: 240
Joined: Fri Nov 04, 2005 2:57 pm

Post 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.
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Post 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.
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

Post by Rovas »

http://www.php.net/manual/en/function.substr.php read it and you will figured it out.
User avatar
waradmin
Forum Contributor
Posts: 240
Joined: Fri Nov 04, 2005 2:57 pm

Post by waradmin »

sorry about that, I didnt even realize I forgot \" on the value, bah.
Post Reply