Page 1 of 1

Populating a <TEXTAREA> tag using MySQL/PHP

Posted: Tue Jul 16, 2002 7:33 pm
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

Posted: Tue Jul 16, 2002 7:40 pm
by rats
textareas have a opening and closing tag. Put it between these..

<textarea attributes > This is my text</textarea>

Posted: Tue Jul 16, 2002 7:44 pm
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>

Posted: Tue Jul 16, 2002 8:43 pm
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"

Posted: Wed Jul 17, 2002 4:11 am
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.