使用tha数据创建的表动态

时间:2015-06-15 17:35:39

标签: php php-5.4 pdflib

我在php上有这个脚本,我需要自动创建表

foreach ( $GetJobResult->Components->Component as $component_index => $component ) {
    $quote_title = ($component_index + 1) . ') ' . $component->Title . "-Machine :\r\n";
    if (isset ( $component->Paper->Family )) {
        if (isset ( $component->Paper->Type ) && isset ( $component->Paper->Color )) {
            if ($component->Ink->FrontColors == '0') {
                $quote_impression = "sans impression\r\n";
            }
            $getPaperInfoResult = $ws->getPaperInfo ( $component->Paper->Family, $component->Paper->Type );
            foreach ( $getPaperInfoResult->PapFamType as $paper_index => $paperinfo ) {
                if (($paperinfo->Ccoul == $component->Paper->Color) && ($paperinfo->Gramm == $component->Paper->Weight)) {
                    $quote_support = $paperinfo->Lfam . ' - ' . $paperinfo->Lcoul . ' - ' . $paperinfo->Gramm . ' g/m2' . "\n";
                    $quote_impression = $component->Ink->FrontColors . ' Couleur(s) ( ' . $component->Ink->FrontColorDesc . ') au recto / ' . $component->Ink->BackColors . ' Couleur(s)' . ' ( ' . $component->Ink->BackColorDesc . ' ) ' . "\n";
                    break;
                }
                // $quote_desc[]= $getPaperInfoResult->PapFamType [$component_index + 1]->Lfam . ' - ' . $getPaperInfoResult->PapFamType [$component_index + 1]->Lcoul . ' - ' . $getPaperInfoResult->PapFamType [$component_index + 1]->Gramm . ' g/m2' . "\n";
            }
        }
        $row++; $col++;
        $tbl = $p->add_table_cell($tbl, $col, $row, $quote_title, $opttitrecontact);
        $imp_text_element1.=$quote_title."-Support : ".$quote_support."-Impression : ".$quote_impression;
    }
 }

它在每个单元格中完成数据并跳过一个单元格放置数据所以我只需要包含数据的表格,我该怎么办呢。

1 个答案:

答案 0 :(得分:0)

通过增加

的变量,我看到了一个可能的问题
$row++; $col++;

这意味着,对于每个附加内容,您都会增加行和单元格。 我希望,只要你需要一个新行,该行应该只会增加。

我想你不仅要在foreach-loop中为每次运行添加一个单元格:     $ tbl = $ p-> add_table_cell($ tbl,$ col,$ row,$ quote_title,$ opttitrecontact); 也许您想添加更多单元格,如果是这样,您应该添加多个add_table_cell()调用以及您要放置的数据。

然而正如Twisty已经提到过的,你可能会更准确地描述你的问题。此外,PDFlib中的support team可能会为您提供进一步的帮助。

相关问题