如何在选择列表中填充用户名。我在允许列表文本框中添加了以下代码。但是选择列表显示PHP代码而不是用户名。
global $user;
$sql = "SELECT name FROM users";
$res = db_query($sql);
while($row = db_fetch_array($res)){
$rows[] = $row['name'];
}
return $rows;
注意:应用程序在D7中运行。 我也按照以下步骤进行操作。
Enable Core module PHP Filter.
Set/Check user permissions: admin/people/permissions#module-php.
Set/Check Text Formats: admin/config/content/formats.
Enable CCK Module. This step is often overlooked. However without CCK Module enabled you wont be able to enter (and thus execute) PHP-code in the Allowed-Values-List window