我想从数据库mpctz_rsform_bruels中获取列Bruel_ID的所有值(数字),以在RSForm下拉框中显示它们。我正在使用此代码:从PHP中提取列值来自PHP
Howeve,我只拉动列的最低值。我怎样才能获得所有的价值? 谢谢,
达尼
编辑:我一直在寻找我发现这个代码是这样运作的:
//<code>
// Prepare the empty array
$items = array();
// Prepare the database connection
$db = JFactory::getDbo();
// Keep this if you'd like a "Please select" option, otherwise comment or remove it
$items[] = "|Selecciona un número[c]";
// Run the SQL query and store it in $results
$db->setQuery("SELECT Bruel_ID, Bruel_ID FROM #__rsform_bruels");
$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
// Eg. m|M-sized T-shirt
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>
但是,它没有显示在下拉框中,只是默认值。任何帮助?
这是正确的查询。 – starvator 2014-09-29 15:48:45
我对PHP和MySQL相当陌生,我可能错过了一些东西。实际上,我需要查询来从mpctz_rsform_bruels中的Bruel_ID列中提取所有行。我错过了什么? – 2014-09-29 15:51:24
向我们显示创建下拉列表的代码。 – consuela 2014-09-29 15:56:51