Hi,
I am trying to send two variables into a function that will help automize some forms so I dont have to rewrite the code multiple times. The two variables are the table name and the name of the column. There is a problem when I tried to use the nameof the column with the selection field.
function multiple_list($tablename, $field) {
$query = "select $field from $tablename";
$result = mysql_query($query) or die ("cant query");
$field = '$'.$field;
echo "$field";
echo "<select multiple name = '$tablename'>\n";
while ($row = mysql_fetch_array($result)) {
extract($row);
echo "<option value= $field>$field\n";
}
echo "</select>";
return;
}
This is what i tried out and it doesnt work. It displays $name, $name in the list which has the correct amount of fields. Any suggestions?
Thanks,
Bakaneko