A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearcontent from database as default for text area in html form - page 1
User InfoPosts
content from database as default for text area in html form#1
I would like to know the easiest way to extract the text from a database field and set it as the default text for a text area.

I am planning at the moment to assiign the field to a variable, and then using javascript set it as the default text, but I am unsure of how to do this last part.

posted date: 2009-04-13 15:10:00


Re: content from database as default for text area in html form#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-13 15:10:01


Re: content from database as default for text area in html form#3
If you(re using a server-side language, it(s not necessary to have the extra javascript step. You can simply populate the value of the "value" attribute. Here(s an example using PHP:<input type="text" name="phoneNumber" value="<?php print($phone_number_from_database); ?>" />

posted date: 2009-04-13 15:16:00


Re: content from database as default for text area in html form#4
In your PHP code, likely above your HTML:// Database connection calls here...$row = mysql_fetch_array();$databaseField = $row["databaseField"];And in your HTML:<textarea name="databaseField" rows="5"> <?php= $databaseField ?></textarea>

posted date: 2009-04-13 15:24:00


Re: content from database as default for text area in html form#5
don(t forget to escape your database contents!<textarea id="foo"> <?php echo htmlspecialchars($databasefield); ?></textarea>otherwise you(ll get problems with content that includes html-tags like (foo </textarea>bar baz(. the bar baz would escape your textarea! this could lead to cross site scripting security problems (if you allow user input) or at least broken html. i used to punish fellow students by opening countless new windows with javascript if they forgot to sanitize the entries in their learning-by-doing guestbook apps. windows with images no sane person evers wants to see. good times :)htmlspecialchars turns <, >, ", &, ... into entities (&lt;, &gt;, &quot;, &amp;, ...), preventing the content to break free.

posted date: 2009-04-13 23:36:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.