# Php retrive value to output to textbox

**URL:** https://forum.kirupa.com/t/php-retrive-value-to-output-to-textbox/279297
**Category:** Uncategorized
**Created:** [January 13, 2009, 2:24am UTC](https://forum.kirupa.com/t/php-retrive-value-to-output-to-textbox/279297 "2009-01-13T02:24:13Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![kitaeshi](https://avatars.discourse-cdn.com/v4/letter/k/9f8e36/32.png) [@kitaeshi](https://forum.kirupa.com/u/kitaeshi)
#### Post date: [January 13, 2009, 2:24am UTC](https://forum.kirupa.com/t/php-retrive-value-to-output-to-textbox/279297/1 "2009-01-13T02:24:13Z")

</div>

Hi all i just learn php & trying to create a updating form, but the form textbox show up a \<? echo $last; ?\> inside the textbox…which is not what i want, i wan it to retrieve the value from the database… below is my code, i have highlight the html form code.

any help would be great

\<?php

$id=$\_GET[‘id’];  
$username=“hamu”;  
$password=“password”;  
$database=“db\_local”;  
mysql\_connect(localhost,$username,$password);

@mysql\_select\_db($database) or die( “Unable to select database”);  
$query=" SELECT \* FROM contacts WHERE id=’$id’";  
$result=mysql\_query($query) or die(mysql\_error());  
$num=mysql\_numrows($result);  
mysql\_close();

$i=0;  
while($i\<$num){  
$first=mysql\_result($result,$i,“first”);  
$last=mysql\_result($result,$i,“last”);  
$email=mysql\_result($result,$i,“email”);

?\>  
\*\*  
\<html\>  
\<body\>  
\<form action=“updated.php” method=“post” action=“update.php”\>  
\<input type=“hidden” name=“ud\_id” value="\<?php echo $id; ?\>"\>  
First Name: \<input type=“text” name=“ud\_first” value=’"\<? echo $first; ?\>"’ /\>\<br\>  
Last Name: \<input type=“text” name=“ud\_last” value="\<? echo $last; ?\>"\>\<br\>  
\<input name=“email” type=“text” id=“email” value="\<? echo $email; ?\>"/\>  
\<input type=“submit”\>  
\</form\>  
\</html\>\*\*

\<?php  
$i++;  
}  
?\>
