Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.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
Php 如何使用codeigniter在视图中使用foreach_Php_Mysql_Codeigniter - Fatal编程技术网

Php 如何使用codeigniter在视图中使用foreach

Php 如何使用codeigniter在视图中使用foreach,php,mysql,codeigniter,Php,Mysql,Codeigniter,我对codeigniter的视图有问题 我想保留标题 示例:标题包含视图的主标题,如产品编号、产品种类和产品数量。以下是所有可用产品的列表 我会尝试编码,但它会重复顶部标题,即产品编号、产品种类和产品数量 结果应该是这样的 Product number: 0011 Product Kind: Beverages Product Quantity: 1000 -------------------------- Fit n Right Coke Pepsi Lemon Juice Gatorade

我对codeigniter的视图有问题

我想保留标题

示例:标题包含视图的主标题,如产品编号、产品种类和产品数量。以下是所有可用产品的列表

我会尝试编码,但它会重复顶部标题,即产品编号、产品种类和产品数量

结果应该是这样的

Product number: 0011
Product Kind: Beverages
Product Quantity: 1000
--------------------------
Fit n Right
Coke
Pepsi
Lemon Juice
Gatorade
etc...

something like that. But my output code was: 

Product number: 0011
Product Kind: Beverages
Product Quantity: 1000
--------------------------
Fit n Right

Product number: 0011
Product Kind: Beverages
Product Quantity: 1000
--------------------------
Coke

Product number: 0011
Product Kind: Beverages
Product Quantity: 1000
--------------------------
Pepsi

Product number: 0011
Product Kind: Beverages
Product Quantity: 1000
--------------------------
Lemon Juice
等等

我的代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
       <title>Beverages</title>
</head>
<body>
<?php

 $funds=strtoupper($fundagent);

   if ($eid_num >0){
       foreach($eid_num as $row):
            $eid=$row->eid;
            $eseries=$row->becno;
            $amount=$row->amount;
            $rescenter=$row->res_center;

 ?>
 <div id="entrystyle" align="center">
table class="box-table-a" valign="top">
   <thead>
     <tr>
         <th colspan="7">Control System</th>
     </tr>
     </thead>
 <?php 
     echo form_open('/beverage/update-data-entry/'.$eid.'/'.strtolower($eseries)); 
 ?>   
 <tr class="gb">
     <td id="fontstyle">
           <label>Budget Earmarking Control No.</label>
           <input type="text" name="becno" id="controlno" size="15" required="required" value="<?php echo $eseries; ?>" onblur="copy_control_no()" readonly="readonly" />
    </td>
    <td id="fontstyle">
        <label>Amount</label>
        <input type="text" name="amount" id="amount" size="15" required="required" value="<?php echo $amount; ?>" readonly="readonly">
   </td>`

饮料
table class=“box-table-a”valign=“top”>
控制系统
预算指定用途管制编号。
控制器:

public function func(){
    .......
    $data['result'] = $this->model->myfunction();  // return resultset from DB
    $this->load->view('folder/filename', $data);
    ........
}
视图:


我想你会从中得到一些想法。

试试这个

function build_view($flake) {
        $this->data['content'] = $this->load->view($flake, $this->data, TRUE);
        $this->load->view('header', $this->data);
    }   

你能分享一些你写的代码吗?请发布一些代码。。或者至少发布您正在获取的变量(数组)是的,这就是我正在使用的,但该代码重复标题,我希望它将显示同样来自db的标题,下面是列表。
<?php 
foreach($result as $value) 
{
     echo $value.'<br/>';
}

?>
function build_view($flake) {
        $this->data['content'] = $this->load->view($flake, $this->data, TRUE);
        $this->load->view('header', $this->data);
    }