Return data to textarea

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
ardan16
Forum Commoner
Posts: 32
Joined: Fri Aug 01, 2008 6:07 am

Return data to textarea

Post by ardan16 »

Hi all can someone tell me if this is possible or if I need different syntax.
the first 3 work and return info, but can you get info to textarea where it is from a medium text field.

Code: Select all

$query = "SELECT name, phone, dept, desc2 FROM report WHERE id=$id";        
$result = @mysql_query ($query); // Run the query.
 
if (mysql_num_rows($result) == 1) { // Valid user ID, show the form.
 
    // Get the user's information.
    $row = mysql_fetch_array ($result, MYSQL_NUM);
    
    // Create the form.
    echo '<h2>Edit a Report</h2>
<form action="one.php" method="post">
<p>Name: <input type="text" name="name" size="15" maxlength="15" value="' . $row[0] . '" /></p>
<p>Phone: <input type="text" name="phone" size="15" maxlength="30" value="' . $row[1] . '" /></p>
<p>Department: <input type="text" name="dept" size="20" maxlength="40" value="' . $row[2] . '"  /> </p>
<p>Report: <textarea name="desc2"  value="' . $row[3] . ' "></textarea> </p>
<p><input type="submit" name="submit" value="Submit" /></p>
<input type="hidden" name="submitted" value="TRUE" />
<input type="hidden" name="id" value="' . $id . '" />
</form>';
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Re: Return data to textarea

Post by markusn00b »

The textarea HTML element does not have a value attribute. Any text to be shown in the textarea is put between the textarea tags.

Code: Select all

<textarea>this is the textarea's value</textarea>
Mark.
ardan16
Forum Commoner
Posts: 32
Joined: Fri Aug 01, 2008 6:07 am

Re: Return data to textarea

Post by ardan16 »

Thanks Markus,
That worked
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Re: Return data to textarea

Post by markusn00b »

ardan16 wrote:Thanks Markus,
That worked
No problem.

Mark.
Post Reply