gpt4 book ai didi

php - 访问同一页面 HTML 中的 PHP 变量

转载 作者:行者123 更新时间:2023-11-29 08:18:50 25 4
gpt4 key购买 nike

如果我有一个包含链接的页面 <a href='edit_info.php?id=1001'>1001</a>在 edit_info.php 页面上,我想使用 id 来查询数据库,例如

SELECT * FROM table WHERE id = $_GET['id']

现在我想用结果填充一堆文本字段。我必须在同一个 php 中完成这一切

('<?php //place all fields in an echo here ?>)

或者有没有办法可以进行查询,然后在 html 中从查询中提取数据?

例如。

<?php //query and results here ?>

<html>
<body>
all my input fields w/ data here
</body>
</html>

最佳答案

您将使用查询中的值设置输入字段。

示例:

<input type="textbox" name="input_name" value="<?php print $valuefromquery; ?>">

并对您想要显示的每个结果执行此操作。还可以使用 PDO/MySQLi查询数据库。

关于php - 访问同一页面 HTML 中的 PHP 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19992539/

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