簡體   English   中英

如何從conventmart分類表獲取數據?

[英]how to get data from virtuemart categories tables?

嗨,我需要在一個表單(RSForm joomla 2.5 )中創建一個下拉列表字段,該字段將從能力模塊類別名稱中提取其值。 我有此代碼塊,我需要根據自己的需要進行自定義,但由於我不知道php,所以我所有的即興創作都以致命錯誤告終,需要再次重新安裝表單:(

我在mysql中的表的名稱是xxx_virtuemart_categories_he_il

類別名稱列在此處category_names

他們的ID在這里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>

加:

$db->query();

之前:

$results = $db->loadObjectList();

在Constancemart中連接到BD的快速簡單的解決方案是:

$db = JFactory::getDbo();
$db->setQuery("SELECT * FROM ... WHERE ...");
$db->query();
$results = $db->loadObjectList();

echo var_dump($results);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM