【问题标题】:Auto fill insert form with $_GET data使用 $_GET 数据自动填充插入表单
【发布时间】:2013-02-12 13:24:01
【问题描述】:

我有一个搜索表单,用户可以在其中在同一字段中插入一位或多位作者的姓名。
我有这个代码:

Author<br /><input type="text" name="autore" value=<?php echo $_GET['autore'] ?> ><br/>

在下一页自动填写作者字段。

我的问题是,如果用户写例如:

san, gli, tro

在 Author 字段中,我只会得到 'san,' ,而我想要 'san, gli, tro' 。

我该如何解决这个问题?

【问题讨论】:

  • 您引用了两个 HTML 属性。为什么不考虑它的重要性呢?

标签: php html cakephp-1.2


【解决方案1】:

如果你这样做会发生什么:

Author<br /><input type="text" name="autore" value="<?php echo $_GET['autore'] ?>" ><br/>

(注意 value 属性周围的引号)

【讨论】:

    【解决方案2】:

    您需要在 php.ini 的值周围加上引号。像这样:

    Author<br /><input type="text" name="autore" value="<?php echo $_GET['autore'] ?>" ><br/>
    

    在您的情况下,最终的 html 将是

    Author<br /><input type="text" name="autore" value=san gli tro ><br/>
    

    所以属性value 的值是san 而另一个是空属性名称。

    加上引号,最终的 html 将是

    Author<br /><input type="text" name="autore" value="san, gli, tro" ><br/>
    

    这是你需要的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多