Populating a <TEXTAREA> tag using MySQL/PHP

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
dickey
Forum Commoner
Posts: 50
Joined: Thu May 16, 2002 8:04 pm
Location: Sydney, Australia

Populating a <TEXTAREA> tag using MySQL/PHP

Post by dickey »

I have no difficulty in populating select, and any input tags by setting the value parameter to equal some php code:

eg

Code: Select all

// database query returned as assoc array

$query = "SELECT * FROM products WHERE status = '".$status."' AND seller = '".$sv_email."'";
$result = mysql_query($query);
$products = mysql_fetch_assoc($result);

// example of populating a text input with retrieved data

<INPUT type="text" name="brand" value="<?=$product&#1111;"brand"]?>">
I am however having trouble similarly populating a textarea as it does not seem to have a value parameter.

Any assistance will be greatly appreciated.

- Andrew
rats
Forum Newbie
Posts: 21
Joined: Fri May 31, 2002 5:55 am

Post by rats »

textareas have a opening and closing tag. Put it between these..

<textarea attributes > This is my text</textarea>
dinke
Forum Newbie
Posts: 1
Joined: Tue Jul 16, 2002 7:44 pm
Contact:

Post by dinke »

You can "populate" texarea just with printing out value of php variable between two textarea tags. For example:

Code: Select all

<textarea name="body" cols="80" rows="25"><? echo htmlspecialchars($body) ?></textarea>
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

yea, whatever is between <textarea> and </textarea> will be displayed in the textarea, and the information in it will be passed with the form.. but make sure to specify a name="something"
User avatar
noguru
Forum Commoner
Posts: 61
Joined: Thu Jun 06, 2002 4:03 am
Location: Just north of the City Of Gold, Land of Milk and Honey

Post by noguru »

Also make sure to put the </textarea> end tag in the same line as the "whatever in between the tags", else you might get a space character added to your value when you pass it or write it into the database. I've had weird encounters in the past when I put the end tag on a seperate line.
Post Reply