在textarea中显示数据库值[重复]

在textarea中显示数据库值[重复]

问题描述:

This question already has an answer here:

I am trying to display the value of a textarea in a form that will enable someone to edit its value. The textarea displays nothing but I checked the database and there is a 2 sentence value. Here is the code I am using:

<textarea rows="5" cols="55" name="P1Bio" value="<?=$record['P1Bio']?>">
</textarea>

P1Bio is the field. On the same form, I am also getting values from textboxes and it is working fine. Here is the code that I am using for text boxes:

<input type="text" size="90" name="P1Email" value="
<?=$record['P1Email']?>">

Can someone please tell me why the textarea is not showing anything? Thank you.

</div>

此问题已经存在 这里有一个答案: p>

  • textarea不能有默认值[复制] 7 answers span> li> ul> div>

    我正在尝试以某种形式显示textarea的值 编辑它的价值。 textarea显示什么,但我检查了数据库,并有一个2句话值。 这是我正在使用的代码: p>

     &lt; textarea rows =“5”cols =“55”name =“P1Bio”value =“&lt;?= $ record [  'P1Bio']?&gt;“&gt; 
    &lt; / textarea&gt; 
      code>  pre> 
     
     

    P1Bio是该字段。 在同一个表单上,我也从文本框中获取值,它工作正常。 以下是我用于文本框的代码: p>

     &lt; input type =“text”size =“90”name =“P1Email”value =“
    &lt;  ?= $ record ['P1Email']?&gt;“&gt; 
      code>  pre> 
     
     

    有人可以告诉我为什么textarea没有显示任何内容吗? 谢谢。 p> div>

There is no value attribute with textareas.

You need to put the content in between the open and closing tags like this:

<textarea rows="5" cols="55" name="P1Bio"><?=$record['P1Bio']?></textarea>

Your php needs to be inside the text area

 <textarea><? Php code? ></textarea>

Try

<textarea rows="5" cols="55" name="P1Bio><?=$record['P1Bio']?></textarea>

Unlike texts (like <input type="text">), content in textareas are inside the tags:

<textarea rows="5" cols="55" name="P1Bio" value=""><?=$record['P1Bio']?></textarea>

Some information regarding this: HTML Tag