prestashop でカスタム モジュールを作成しています。今、私のphpファイルには次のような関数があります
public function hookHome($params)
{
$defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT'));
global $cookie, $smarty;
$value=array();
$sql_select="SELECT DISTINCT country_name,country_ISO from "._DB_PREFIX_."storedetails where status='1'";
$result=Db::getInstance()->ExecuteS($sql_select);
print_r($result);
while($row=mysql_fetch_assoc($result))
{
$value[] = $row;
}
$smarty->assign('array',$value);
$smarty->assign('default',$defaultLanguage);
return $this->display(__FILE__, 'storedetails.tpl');
}
このコードの背後にある概念は、すべての値を配列に格納し、それらをビュー ファイル (スマート テンプレート) に取得することです。
ここで私がやっているとき print_r($result); 配列を表示しています。値はこのようになっています
Array ( [0] => Array ( [country_name] => [country_ISO] => select ) [1] => Array ( [country_name] => Germany [country_ISO] => DE )...
しかし、次の行から次のようなエラーが表示されていますWarning: mysql_fetch_assoc() expects parameter 1 to be resource, array given in filename.php line number
私の.tplファイル(ビューファイル)には、次のような値を取得したいコードがあります
<select onchange="selectCountry(this.value)">
<option value="Select">Select</option>
{foreach from=$array item=row}
<option value="{$row.country_ISO}" id="{$row.country_name}">{$row.country_name}</option>
{/foreach}
</select>
では、このエラーが発生する理由と、この問題を解決する方法を誰かが親切に教えてもらえますか?ヘルプや提案は非常に重要です。ありがとう