在textarea中显示数据库值

时间:2016-10-07 17:34:04

标签: php html

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

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

P1Bio就是这个领域。在同一个表单上,我也从文本框中获取值,它工作正常。这是我用于文本框的代码:

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

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

4 个答案:

答案 0 :(得分:5)

textareas没有value属性。

您需要将内容放在开放标记和结束标记之间,如下所示:

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

答案 1 :(得分:1)

你的php需要在文本区域内

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
    "http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
    <constant name="struts.devMode" value="true" />
    <!-- the next two lines are ONLY if you want to override a content handler, and since mine is custom it would be with your own impl, however without pain you can only overrride because I think think the extensions are hard coded... so you can't just add your own, could be wrong -->
    <bean type="org.apache.struts2.rest.handler.ContentTypeHandler" name="flexjson" class="com.kenmcwilliams.s2.result.FlexJsonHandler" />
    <constant name="struts.rest.handlerOverride.json" value="flexjson"/>

    <constant name="struts.action.extension" value="xhtml,,xml,json,action"/>
    <constant name="struts.mapper.class" value="org.apache.struts2.dispatcher.mapper.PrefixBasedActionMapper" />
    <constant name="struts.mapper.prefixMapping" value="/rest:rest,:struts"/>
    <constant name="struts.convention.action.mapAllMatches" value="true"/>
    <constant name="struts.convention.default.parent.package" value="my-conventions"/>
    <constant name="struts.rest.namespace" value="/rest"/>

    <package name="my-conventions" namespace="/"  extends="convention-default" >
        <result-types>
            <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
        </result-types>
        <!-- Following is required for some reason -->
        <global-allowed-methods>execute,input,back,cancel,browse,save,delete,list,index,show,create,update,destroy,edit,editNew</global-allowed-methods>
    </package>

    <package name="my-rest" namespace="/rest" extends="rest-default">
        <result-types>
            <result-type name="flexjson" class="com.kenmcwilliams.s2.result.FlexJsonResult"/>
        </result-types>
    </package>

    <!-- not needed unless you're planning on using tiles -->
    <package name="my-tiles" namespace="/tiles" extends="tiles-default" strict-method-invocation="false">
        <result-types>
            <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
        </result-types>
    </package>
</struts>

答案 2 :(得分:1)

尝试

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

答案 3 :(得分:0)

与文字(例如<input type="text">)不同,textarea中的内容位于代码内:

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

有关此问题的一些信息:HTML Tag