hi, another question here. i'm a beginner at php and i need a php script to automatically retrieve data from a database and fill in a form. all the data is in the database and I already have a script to search and return the results.
I just don't know how to generate a form that will be automatically filled from the search.

I hope you can help!

yes you can show database value in textbox....First take a look at this example....


To show value from database into database do the following:-

<?php
<html>
<head><title>Textbox manipulation</title>
</head>
<?php
$con = mysql_connect("localhost","root","password")
or
  die('Could not connect: ' . mysql_error());
  
mysql_select_db("db_name", $con);

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

while($row = mysql_fetch_array($result))
  {
echo "<input type='text' name='name' id='name' value='".$row['name']."' />"

  echo "<br />";
  }

mysql_close($con);
?>

Actually to show value in textbox you can use following...

<html>
<head><title>Gallery Script</title></head>
<body>
<?php
echo "<input type='text' name='name' id='name' value='sad' />"
?>
</body>
</html>

OR

<html>
<input type="text" value=<?php echo "Hi"?>>
</html>

Hope it's clear!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.