开发者

Display data from sql database to a textbox

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

$query = mysql_query("SELECT * FROM  `PropertyI开发者_如何学JAVAnfo` 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 echoing a textbox with those variables in the value="" attribute

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


It's as simple as:

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


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']' />";                      
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜