gpt4 book ai didi

php - 使用输入添加对 href 的查询

转载 作者:行者123 更新时间:2023-12-04 05:36:23 26 4
gpt4 key购买 nike

我有一个

<input type=text name=search />

我想将 input 的值添加到我的 href
<a href='index.php?search=$search>submit</a>

但我认为这不能单独在 php 上工作,对吗?

我如何在点击时将我的输入值添加到我的 href 中?

注意:需要以这种方式出现在浏览器 url 菜单中
index.php?search=anyvalue

一旦他们点击它。因为我正在使用分页

最佳答案

纯 HTML - 不需要 PHP 或 JavaScript

<form action="index.php" method="get">
<input type="text" name="search" />
<button type="submit">Submit</button>
</form>

单击后,它会将用户带到: index.php?search={value of input}
要使分页工作,它将是:
<a href="index.php?search=<?php echo $_GET['search']; ?>&page=2">Page 2</a>
<a href="index.php?search=<?php echo $_GET['search']; ?>&page=3">Page 3</a>

关于php - 使用输入添加对 href 的查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11875577/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com