2

I am trying to retrieve data from mysql and put into text area. Others data that insert to text box works well but i faced problem when want to insert into text area.

echo'<textarea name="abstract" id="abstract" size="200" value="'.$abstract.'"></textarea>';

I have fetch my query out with

    $result = mysql_query("SELECT * FROM publication where file_id='$id'");
    $row1 = mysql_fetch_array($result);
    $abstract=$row1['abstract'];

Thanks for helping me...

6 Answers 6

4

Try this one

echo'<textarea name="abstract" id="abstract" size="200">'.$abstract.'</textarea>';

or 
<textarea name="abstract" id="abstract" size="200"><?php echo $abstract?></textarea>
Sign up to request clarification or add additional context in comments.

2 Comments

The first statement echo'<textarea name="abstract" id="abstract" size="200">$abstract</textarea>'; , will not work as expected ... PHP string interpolation doesn't work with ' single quote ... echo 'hello $name'; will print hello $name
echo'<textarea name="abstract" id="abstract" size="200">'.$abstract.'</textarea>'; will work
3

Textarea doesn't have value tag:

echo'<textarea name="abstract" id="abstract" size="200">'.$abstract.'</textarea>';

Comments

1

use as

echo '<textarea name="abstract" id="abstract" size="200">'.$abstract.'</textarea>';

Comments

0

You need to put your $abstract like this :

echo'<textarea name="abstract" id="abstract" size="200">'.$abstract.'</textarea>';

Comments

0

Try this

<textarea name="abstract" id="abstract" size="200" ><?php echo $abstract; ?></textarea>

Comments

0

If you want to avoid concatenation you could enclose the variable within curly braces to avoid any confusion, if it does, in the following manner

echo "<textarea name='abstract' id='abstract' size='200'>{$abstract}</textarea>";

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.