duankeng2026 2010-12-23 19:25
浏览 20
已采纳

文本框无法正确显示

texbox

I'm using PHP to retrieve the data from a database.

Every time I retrieve it from database it doesn't show the whole letters. It's being removed off after space???

I want like the first text box, show all the letters

both code doesn't work

<input type="text" class="textinput"  value=' . $r['newsletter_title'] . '>

<input type="text" class="textinput"  value=' . htmlspecialchars($r['newsletter_title']) . '>

I checked the database it's showing the whole letters "80% sale On Day"

Does anyone knows what causes this? Any solution please!!!

  • 写回答

4条回答 默认 最新

  • dongqie4402 2010-12-23 19:32
    关注

    You need to quote the value (and use htmlspecialchars):

    <input 
        type="text" 
        class="textinput" 
        name="newsletter_title" 
        id="newsletter_title" 
        value="' . htmlspecialchars($r['newsletter_title']) . '" 
        />
    

    Which generates:

    <input 
        type="text" 
        class="textinput" 
        name="newsletter_title" 
        id="newsletter_title" 
        value="80% sale On Day" 
        />
    

    Otherwise you're generating invalid html/xml (which is why it isn't working)...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元