php 将sql数据库中的数据显示到文本框

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5994526/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:08:13  来源:igfitidea点击:

Display data from sql database to a textbox

phpsqltextbox

提问by Jason

I am performing a search of my sql database, and assigning the data from each row to a variable. Ex.

我正在搜索我的 sql 数据库,并将每一行的数据分配给一个变量。前任。

$query = mysql_query("SELECT * FROM  `PropertyInfo` WHERE  `sitestreet` LIKE  '$street'");
// display query results
while($row = mysql_fetch_array($query))
    {
        $sitestreet = $row['sitestreet'];
        $sitestate =$row['sitestate'];                           
    } 

Now my question is how do I get that info to display as text in a text box?

现在我的问题是如何让该信息在文本框中显示为文本?

Thanks!

谢谢!

回答by mellamokb

By echoing a textbox with those variables in the value=""attribute

通过在value=""属性中回显带有这些变量的文本框

echo "<input type='text' id='sitestreet' value='$sitestreet' />"
echo "<input type='text' id='sitestate' value='$sitestate' />"

回答by eykanal

It's as simple as:

这很简单:

<input value='<?php echo $sitestreet; ?>'>

回答by SIFE

You can fetch and assign in some time:

您可以在一段时间内获取和分配:

while($row = mysql_fetch_array($query))
    {
      echo "<input type='text' id='sitestreet' value='$row['sitestreet']' /><br />
            <input type='text' id='sitestate' value='$row['sitestate']' />";                      
    }