我想從數據庫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