.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Pankaj Mishra
alex morco
Imran Ghani

Home >> Code Snippets >> Collections >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Fetch data from database to textbox in php

Posted By:satyapriyanayak       Posted Date: February 24, 2014    Points: 40    Category: Collections    URL: http://www.dotnetspark.com  

In this Code Snippets we will know how to fetch data from database to textbox in php.


$con = mysql_connect( 'localhost', 'root', '' );

if( !$con )


 die( 'Could not connect: ' . mysql_error() );




 mysql_select_db( 'home_work', $con );

 $result = mysql_query( "SELECT * FROM test" );

 while( $row = mysql_fetch_array( $result ) )




 <input name="firstname" type="text" value="<?php echo( htmlspecialchars( $row['firstname'] ) ); ?>" />

 <input name="lastname" type="text" value="<?php echo( htmlspecialchars( $row['lastname'] ) ); ?>" />







Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend