久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <tfoot id='hNARB'></tfoot>

    <small id='hNARB'></small><noframes id='hNARB'>

        <legend id='hNARB'><style id='hNARB'><dir id='hNARB'><q id='hNARB'></q></dir></style></legend>

          <bdo id='hNARB'></bdo><ul id='hNARB'></ul>
        <i id='hNARB'><tr id='hNARB'><dt id='hNARB'><q id='hNARB'><span id='hNARB'><b id='hNARB'><form id='hNARB'><ins id='hNARB'></ins><ul id='hNARB'></ul><sub id='hNARB'></sub></form><legend id='hNARB'></legend><bdo id='hNARB'><pre id='hNARB'><center id='hNARB'></center></pre></bdo></b><th id='hNARB'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='hNARB'><tfoot id='hNARB'></tfoot><dl id='hNARB'><fieldset id='hNARB'></fieldset></dl></div>

        PHP While 循環只顯示最后一行

        PHP While loop displaying only last row(PHP While 循環只顯示最后一行)

        <small id='nMAxR'></small><noframes id='nMAxR'>

        <legend id='nMAxR'><style id='nMAxR'><dir id='nMAxR'><q id='nMAxR'></q></dir></style></legend>
            <tbody id='nMAxR'></tbody>

                <bdo id='nMAxR'></bdo><ul id='nMAxR'></ul>
              • <i id='nMAxR'><tr id='nMAxR'><dt id='nMAxR'><q id='nMAxR'><span id='nMAxR'><b id='nMAxR'><form id='nMAxR'><ins id='nMAxR'></ins><ul id='nMAxR'></ul><sub id='nMAxR'></sub></form><legend id='nMAxR'></legend><bdo id='nMAxR'><pre id='nMAxR'><center id='nMAxR'></center></pre></bdo></b><th id='nMAxR'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='nMAxR'><tfoot id='nMAxR'></tfoot><dl id='nMAxR'><fieldset id='nMAxR'></fieldset></dl></div>
                <tfoot id='nMAxR'></tfoot>

                  本文介紹了PHP While 循環只顯示最后一行的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在使用 TCPD 庫來生成表格的 PDF.

                  I'm using TCPDF library to generate PDF of a table .

                  表的行數很少,比如 10

                  Table has few number of rows say 10

                  其中兩行發票編號相同78650"

                  現在我按發票編號選擇,并根據需要生成帶有兩行的 PDF.

                  Now i am selecting by invoice number and as desired it should generate PDF with two rows.

                  但它只獲取最后一行的第二行.那是 Serial no 2 只被拿走了.

                  But instead it is only fetching the second row that is the last row. That is Serial no 2 is only taken .

                  代碼如下:

                  <?php
                  require_once('TCPDF/tcpdf.php');
                  $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
                  $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
                  $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
                  
                  if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
                  require_once(dirname(__FILE__).'/lang/eng.php');
                  $pdf->setLanguageArray($l);
                  }
                  $pdf->SetFont('helvetica', '', 9);
                  $pdf->AddPage();
                  
                  $html1 = '<table  cellspacing="0" class="table table-striped">
                  <tr>
                  
                  <th>SL No.</th>
                  
                  <th>Product</th>
                  <th>Description</th>
                  <th>Qty</th>
                  <th>Total</th>
                  </tr>';
                  
                  $sql = ("select * from invoice WHERE invoice_no = 78650 ORDER BY invoice_id ASC");
                  $result=mysqli_query($connection,$sql);
                  $i = 1;
                  while($row = mysqli_fetch_array($result)){
                  $pr = $row['product'];  
                  $dr = $row['description'];  
                  $qty = $row['qty']; 
                  $total = $row['total']; 
                  
                  $html2 =  "<tr>
                  
                  <td>".$i."</td>                         
                  <td>".$pr."</td>
                  <td>".$dr."</td>
                  <td>".$qty."</td>
                  <td>".$total."</td>
                  </tr>";
                  
                  $i++; } 
                  
                  $sql_1 = ("select *,SUM(total)as tot from invoice WHERE invoice_no = 78650 GROUP BY invoice_no");
                  $result_1=mysqli_query($connection,$sql_1);
                  $row_1 = mysqli_fetch_array($result_1);
                  $tot = $row_1['tot']; 
                  $html3 =    "<tr>
                  <td></td>
                  
                  <td></td>
                  <td></td>
                  <td>Total: </td>
                  <td>".$tot."</td>
                  </tr>                       
                  </table>";
                  $html = $html1.$html2.$html3;
                  $pdf->writeHTML($html, true, 0, true, 0);
                  $pdf->lastPage();
                  $pdf->Output('htmlout.pdf', 'I');
                  ?>
                  

                  推薦答案

                  那是因為對于迭代,您正在替換 $html2 的內容.您需要改為附加內容.

                  That's because for iteration you're replacing the content of $html2. You will need to append the content instead.

                  因此,將空白的 $html2 變量移出循環并在迭代循環時附加結果.

                  So take the blank $html2 variable outside the loop and append the result as you iterate the loop.

                  代碼看起來像這樣,

                  $html2="";
                  while($row = mysqli_fetch_array($result)){
                  $pr = $row['product'];  
                  $dr = $row['description'];  
                  $qty = $row['qty']; 
                  $total = $row['total']; 
                  
                  $html2 = $html2."<tr>
                  <td>".$i."</td>                         
                  <td>".$pr."</td>
                  <td>".$dr."</td>
                  <td>".$qty."</td>
                  <td>".$total."</td>
                  </tr>";
                  
                  $i++; 
                  
                  } 
                  

                  這篇關于PHP While 循環只顯示最后一行的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環)
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數)
                  Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結果填充變量)
                  MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“localhost的訪問被拒絕)
                  <legend id='JxgcM'><style id='JxgcM'><dir id='JxgcM'><q id='JxgcM'></q></dir></style></legend><tfoot id='JxgcM'></tfoot>

                      <bdo id='JxgcM'></bdo><ul id='JxgcM'></ul>

                          <small id='JxgcM'></small><noframes id='JxgcM'>

                            <tbody id='JxgcM'></tbody>
                          • <i id='JxgcM'><tr id='JxgcM'><dt id='JxgcM'><q id='JxgcM'><span id='JxgcM'><b id='JxgcM'><form id='JxgcM'><ins id='JxgcM'></ins><ul id='JxgcM'></ul><sub id='JxgcM'></sub></form><legend id='JxgcM'></legend><bdo id='JxgcM'><pre id='JxgcM'><center id='JxgcM'></center></pre></bdo></b><th id='JxgcM'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='JxgcM'><tfoot id='JxgcM'></tfoot><dl id='JxgcM'><fieldset id='JxgcM'></fieldset></dl></div>
                            主站蜘蛛池模板: 99精品观看 | 日本黄色大片免费 | 日韩精品视频中文字幕 | 亚洲国产成人精品女人久久久 | www.99精品| 国产精品一码二码三码在线 | 国产精品久久久99 | 97精品国产 | 高清亚洲 | 亚洲夜夜爽 | 密色视频 | 精品国产一区二区三区免费 | 狠狠av | 草草影院ccyy | 午夜精品久久久久久不卡欧美一级 | 天天舔天天 | 国产精品美女 | 欧美一级特黄aaa大片在线观看 | 免费一级片 | 欧美日韩一区二区三区四区五区 | 日本成人综合 | 精品欧美二区 | 国产精品永久免费视频 | 国产精品明星裸体写真集 | 91久久久www播放日本观看 | 伊人网在线看 | 久久久精品视频一区二区三区 | 99热视| 精品欧美黑人一区二区三区 | 亚洲成人精品视频 | 99热激情 | 亚洲视频二区 | 青青久在线视频 | 国产电影精品久久 | 亚洲第一在线 | 祝你幸福电影在线观看 | 日韩中文字幕免费在线观看 | 成人综合在线视频 | 午夜视频在线免费观看 | 亚洲精品久久国产高清情趣图文 | 成人性生交大片免费看中文带字幕 |