here is an example of where it would work. say you have a table called test, with fields, field1, field2, field3, field4.
$q = "SELECT * FROM test WHERE something";
$r = mysql_query($q);
$data = mysql_fetch_array($r);
extract($data);
//now $data['field1'] is $field1 etc...
preg_replace("/value='[(\w+)]'/e", "value='$\\1'", $html);
where $html is the source of the html page.
something like that should work, i didnt test it but i think its right. see how it goes.