To display
MySql data in
Textbox we need to use Php script in HTML script. below is the simple example to display data in
Text Box ....
In this example you will see Text Box displaying data directly from the database
Suppose this is the MySql database containing some data
NAME
CONTACT
EMAIL
ADDRESS
MUKESH SINGH
9475563334
Dhanbad Jharkhand
PRASHANT PASHWAN
9475551446
Madhapura Bihar
SACHIN
8986822639
Parasnath Jaharkhand
Php code and Html code
<?php
@mysql_connect( 'localhost','root','') or die( 'check username and password');
@mysql_select_db( 'record') or die( 'not connected');
?>
<!DOCTYPE html>
<html>
<head><title> expertcodingmaster.com</title>
<style type ="text/css">
table
{
width:50em;
}
fieldset
{
width:20em;
background-color:lightgreen;
}
.sty
{
width:16em;
height:4em;
}
</style>
</head>
<body bgcolor ="lavender">
<div>
<center>
<fieldset>
<legend><font size ="5px" color ="blue"> Fetching of data from Sql to Textbox </font></legend>
<?php
if (isset( $_POST['submit']))
{
$email = $_POST['email'];
$address = $_POST['address'];
$contact = $_POST['contact'];
if (empty( $email))
{
echo "<font color =red size =4px> please enter email address </font> ";
}
else
{
$query = mysql_query ("select * from employee where email='$email'");
$result = mysql_fetch_array ($query);
$n = $result['name'];
$a = $result['address'];
$c = $result['contact'];
}
}
?>
<form method ="post" action ="" >
<table border ="1" cellspacing ="10" cellpadding ="10" rules ="rows">
<tr><td colspan ="2"> enter your email address       <input type ="email" name ="text"> <input type ="submit" name ="submit" value ="submit"></td></tr>
<tr><td> Name </td><td><input type ="text" readonly name ="name" value ="< ?php if(isset( $n))
{
echo $n;
}
?> "></td></tr>
<tr><td> Address </td><td> <input class ="sty" type ="text" name ="address" readonly value =" <?php if(isset( $a))
{
echo $a;
}
?> "></td></tr>
<tr><td> Contact No. </td><td><input type ="text" readonly name ="contact" value =" <?php if(isset( $c))
{
echo $c;
}
?> "></td></tr>
</table>
</fieldset>
</center>
</div>
</body>
</html>