In this blog we will know how to fetch data from database to
textbox in php.
<?php
$con = mysql_connect( 'localhost', 'root', '' );
if( !$con )
{
die( 'Could not
connect: ' . mysql_error() );
}
else
{
mysql_select_db(
'home_work', $con );
$result =
mysql_query( "SELECT * FROM test" );
while( $row =
mysql_fetch_array( $result ) )
{
?>
<form>
<input
name="firstname" type="text" value="<?php echo(
htmlspecialchars( $row['firstname'] ) ); ?>" />
<input
name="lastname" type="text" value="<?php echo(
htmlspecialchars( $row['lastname'] ) ); ?>" />
</form>
<?php
}
}
?>