简体   繁体   English

使用dompdf循环codeigniter

[英]loop codeigniter with dompdf

I want to fill an PDF with data from my database. 我想用我的数据库中的数据填充PDF。 Now this is working except that i cant get a loop in it. 现在这是有效的,除了我不能得到一个循环。 With what i got now it gives the wrong data in the output. 凭借我现在所拥有的,它在输出中提供了错误的数据。

In my model i got: 在我的模型中我得到:

public function getGoogle($id)  {
    $this->db->select('*');
    $this->db->where('quickscan_id', $id);
    $query = $this->db->get('zoekwoorden_quickscan_google_gebruik');

    return $query->row_array();
}

And in my controller: 在我的控制器中:

    $view["googles"] = $this->pdfs->getGoogle($id);

Then my view where i create the PDF: 然后我的视图我在哪里创建PDF:

$googleloop = '';
foreach ($googles as $google)
{
        $zoekwoord = $google['zoekwoord'];
        $volume_pm = $google['colume_pm'];
        $positie = $google['positie'];

        $googleloop .= "<div id='zoekwoorddiv'>
                            <div id='gzoekwoordleft'>
                                ".$zoekwoord."
                            </div>
                            <div id='gzoekwoordcenter'>
                                ".$volume_pm."
                            </div>
                            <div id='gzoekwoordright'>
                                ".$positie."
                            </div>
                        </div>";
};

Im calling the variable $googleloop in my $html variable as output for the PDF. 我在$html变量中调用$googleloop变量作为PDF的输出。 But in my PDF it gives me only the first in the array from $googles , and then only the first characters of the $google['volume_pm'] , etc 但是在我的PDF中它只给了我来自$googles的数组中的第一个,然后只有$google['volume_pm']的第一个字符,等等

I understand if this is kinda confusing, but i really don't know how to explain this better. 我理解这是否有点令人困惑,但我真的不知道如何更好地解释这一点。

row_array()只返回一行,您需要对整个结果集使用result_array()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM