Hey all!

I'm pulling my hair out trying to figure out this noodle scratcher. I have a form that takes a users first and last name, then posts that to process.php where it pulls all the info for that person from mySQL database. The DB connection is fine, and I can echo the variable in process.php sucessfully. I run into trouble when trying to display that variable in a textarea.

Code:

<?php

include("global.inc.php");

//Define credentials
$link = mysql_connect("DOMAIN","USERNAME","PASSWORD");
if (!$link)
{
die('Could not connect: ' . mysql_error());
}

//Define database and connect to database
mysql_select_db("CLS_1",$link);

//Get Form Info
$FirstName = $_POST["FirstNameQuery"];
$LastName = $_POST["LastNameQuery"];

//Define query and set it to a variable
$result = mysql_query("SELECT * FROM cls_app_form WHERE FirstName = '$FirstName' AND LastName = '$LastName'");

//Set aquired row array to variable
$row = mysql_fetch_array($result);

$AdditionalTraining = $row['AdditionalTraining'];

echo $AdditionalTraining;

//Everything works to here!!!  The AdditionalTraining variable is displayed.

?>

//Style to set the textarea to the full length of the cell
<head>

<style type="text/css">
textarea {width:100%;}
</style>

</head>


//Here's where I run into problems.
<body>

<tr>
    <td align="right">Additional Training</td>
    <td colspan="5">
    <textarea name='AdditionalTraining' rows=6 cols=30 readonly="enabled" value="<?php echo $AdditionalTraining; ?>">
    </textarea>
    </td>
</tr>

</body>

//Nothing gets displayed in the textarea!!!!!

Recommended Answers

All 2 Replies

Just echo it between your textarea tags:

<textarea name='AdditionalTraining' rows=6 cols=30 readonly="enabled">
<?php echo $AdditionalTraining; ?>
</textarea>

In case you don't see the difference in what @elbeato posted, there is no "value" property when using "textarea" as there is when using "input".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.