Jason
Jason

Reputation: 265

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  `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!

Upvotes: 1

Views: 36501

Answers (3)

SIFE
SIFE

Reputation: 5695

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

Upvotes: 0

eykanal
eykanal

Reputation: 27017

It's as simple as:

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

Upvotes: 1

mellamokb
mellamokb

Reputation: 56769

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' />"

Upvotes: 2

Related Questions