Autofill Values To a Text Input Box
Form
<p style=”display:visible;”>
<label for=”myfield”>Name:</label>
<input type=”text” name=”myname” id=”myname” value=”<?php
$column=”name”;
get_text($column,$id);
?>” />
</p>
Function
function get_text($mycolumn,$myid) {
//This outputs what we want; the variable which is passed in to the function
$command= “SELECT $mycolumn FROM counselling_report where id=’$myid'”;
$result = mysqli_query($db, $command);
while ($row = mysqli_fetch_assoc($result)) {
$var=$row[‘name’];
echo $var;
}
}
January 10, 2012 by kent