Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter:无法在查看页面中显示来自购物车选项的特定值_Codeigniter - Fatal编程技术网

Codeigniter:无法在查看页面中显示来自购物车选项的特定值

Codeigniter:无法在查看页面中显示来自购物车选项的特定值,codeigniter,Codeigniter,我用codeigniter做了一个购物车 我在购物车中添加了几本书的详细信息。我想在不同的div中显示特定的cart选项值。但我无法展示它 我尝试了下面的代码,但使用此代码,我可以一次获得所有选项值 请帮帮我 Controller.php view.php --------------- ---------------- <?php $i = 1; ?> <?php foreach($this->cart->contents()

我用codeigniter做了一个购物车

我在购物车中添加了几本书的详细信息。我想在不同的div中显示特定的cart选项值。但我无法展示它

我尝试了下面的代码,但使用此代码,我可以一次获得所有选项值

请帮帮我

Controller.php view.php

   ---------------
   ----------------
 <?php $i = 1; ?>
           <?php foreach($this->cart->contents() as $items): ?>                                                     
             <td> //i want to display here only the value of the a name
                 <?php foreach ($this->cart->product_options($items['rowid']) as $aname => $option_value): ?>
                          <?php  echo $option_value;    ?> 
                           <?php endforeach; ?> 
            </td>                                                                                                      
          <?php $i++; ?>
        <?php endforeach; ?>
           -----------------
            ----------------

更新

我想这次我成功了

<?php $i = 1; ?>
       <?php foreach($this->cart->contents() as $item): ?>                                                     
         <td> //i want to display here only the value of the a name
              <?php  echo $item['options']['covername'];    ?> 
        </td>                                                                                                      
      <?php $i++; ?>
    <?php endforeach; ?>

//我只想在这里显示名称的值

您正在显示
,但
名称
不在我的购物车选项中。我想显示购物车选项中的特定值。假设我想在我的查看页面中显示来自我的购物车选项的
covername
。如何执行此操作?出现错误:
无法在第267行的D:\xampp\htdocs\…\application\views\cart\cart.php中将字符串偏移量用作数组并粘贴结果请在第一个foreach之前粘贴code
var\u dump($this->cart->contents())
后,用输出更新我的答案。请给我建议一个解决办法
          array(1) { ["3705f19b9e71159a8b1a84079cfa8a3f"]=> array(7) { ["rowid"]=> string(32) 
         "3705f19b9e71159a8b1a84079cfa8a3f" ["id"]=> string(2) "17" ["qty"]=> string(1) "1" ["price"]=> 
         string(2) "46" ["name"]=> string(39) "Budhhiyoga Of the Gita And other Essays" ["options"]=> 
          array(3) { ["aname"]=> string(16) "Sri Anirvan" ["covername"]=>  string(11) 
        "Hard Cover" ["Bimg"]=> string(13) 
        "DSC00a009.JPG" } ["subtotal"]=> int(46) } }
<?php $i = 1; ?>
       <?php foreach($this->cart->contents() as $item): ?>                                                     
         <td> //i want to display here only the value of the a name
              <?php  echo $item['options']['covername'];    ?> 
        </td>                                                                                                      
      <?php $i++; ?>
    <?php endforeach; ?>