从mysql数据库prestashop填充多个select

时间:2015-07-21 04:51:32

标签: javascript php ajax prestashop-1.5

我想创建一个带有添加/删除按钮的多重选择,并且我希望从mysql查询中获取多个选择中的值。我的问题是如何填充查询结果以选择列表值? 我的代码如下: Product.tpl

         <form>
         <fieldset>
         <form name="formName1">
         <select name="selectfrom" id="select-from" multiple size="5" >
         <option value="1?>">Item1</option>
         <option value="2">Item 2</option>
         <option value="3">Item 3</option>
         <option value="4">Item 4</option>
         </select>

         <a href="JavaScript:void(0);" id="btn-add">Add &raquo;</a>
         <a href="JavaScript:void(0);" id="btn-remove">&laquo; Remove</a>

         <select name="selectto" id="select-to" multiple size="5">
         <option value="5">Item 5</option>
         <option value="6">Item 6</option>
         <option value="7">Item 7</option>
         </select>
         <input type="button" onClick="myFunction()" value="Submit form">
         </fieldset>
         </form>

我的php文件代码是:

       public function products_configure($url){
       $productsel = "Select id_product,name from ". _DB_PREFIX_ ."product_lang";
          $products = Db::getInstance()->executeS($productsel);
              foreach($products as $product){
                $productintid = $product['id_product'];
                $productintname = $product['name'];
                   }
                  $this->context->smarty->assign(array(
                  'url' => $url
                   ));
              return $this->fetchTemplate('/views/templates/back/products.tpl');
               } 

任何人都可以告诉我如何将$ productintname用于tpl文件中的选项值。

0 个答案:

没有答案