Conjurer Posted September 29, 2008 Share Posted September 29, 2008 I saw some code somewhere and can't remember now how you do it. But they had a text box in a form and they wanted to show the user the current value that they returned from a database and then give them an option to change it. They set a variable like $foo = "bar" and then somehow used php for the default value of the form box to get it to show the value "bar" How do you do that? Link to comment https://forums.phpfreaks.com/topic/126219-how-do-you-load-a-php-variable-value-into-a-form-field-as-a-default-value/ Share on other sites More sharing options...
Lodius2000 Posted September 29, 2008 Share Posted September 29, 2008 <?php $foo = //mysql query that returns one text based result print "<form>"; print "<input type='text' name='title' value='$foo'/>"; print "</form>"; ?> Link to comment https://forums.phpfreaks.com/topic/126219-how-do-you-load-a-php-variable-value-into-a-form-field-as-a-default-value/#findComment-652706 Share on other sites More sharing options...
Conjurer Posted September 29, 2008 Author Share Posted September 29, 2008 oh wow! That isn't what I was thinking of, but it will work for me. Link to comment https://forums.phpfreaks.com/topic/126219-how-do-you-load-a-php-variable-value-into-a-form-field-as-a-default-value/#findComment-652711 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.