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? Quote 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>"; ?> Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.