您好,我需要在表单(RSForm joomla 2.5 )中创建一个下拉列表字段,该字段将从deremmart 类别名称中提取其值。我有这段代码需要根据我的需要进行定制,但由于我不知道 php,所以我所有的即兴创作都以致命错误告终,需要再次重新安装表单:(
我在 mysql 中的表的名称是xxx_virtuemart_categories_he_il
这里列出了类别的名称category_names
他们的身份证在这里virtuemart_category_id
这是代码块我如何更改它?
//<code>
// Prepare the empty array
$items = array();
// Prepare the database connection
$db = JFactory::getDbo();
// Run the SQL query and store it in $results
$db->setQuery("SELECT your_value, your_label FROM #__your_table");
$results = $db->loadObjectList();
// Now, we need to convert the results into a readable RSForm! Pro format.
// The Items field will accept values in this format:
// value-to-be-stored|value-to-be-shown
foreach ($results as $result) {
$value = $result->your_value;
$label = $result->your_label;
$items[] = $value.'|'.$label;
}
// Multiple values are separated by new lines, so we need to do this now
$items = implode("\n", $items);
// Now we need to return the value to the field
return $items;
//</code>