display variable variables in a text field in a form

From: Date: Fri, 18 May 2001 10:28:52 +0000
Subject: display variable variables in a text field in a form
Groups: php.db 
Request: Send a blank email to php-db+get-9424@lists.php.net to get a copy of this message
$fields=array("fname","lname","dept","city","ophone","hphone","fax","email"); $sqlstmt="SELECT * FROM contacts WHERE id='$id'"; $result=mysql_query($sqlstmt); foreach ($fields as $values) { print " <tr $rowcolor>\n <td>$fieldn</td>\n <td><input type=\"text\" name=\"$values\" value=\"$$values\"></td>\n </tr>\n"; } I'm not sure how to explain this, when do the above (I have ommited certain portions of my codes). The form will be displayed as: First Name $fname Last Name $lname Department $dept City $city Office Phone $ophone Handphone $handphone Fax $fax E-mail $email How do I make it to display the actual values of $fname instead of the variable name itself? Thanks in advance.. regards

« previous php.db (#9424) next »