如何使用FPDF从MySQL表中生成特定ID的PDF发票。

huangapple go评论98阅读模式
英文:

How to generate a pdf invoice from mySQL table using FPDF for a specfic id

问题

I understand your request. Here's the translated code portion you provided:

  1. <?php
  2. require('fpdf.php');
  3. // A4 width: 219mm
  4. // Default margin: 10mm each side
  5. // Writable horizontal: 219-(10*2)=189mm
  6. $pdf = new FPDF('P','mm','A4');
  7. $pdf->AddPage();
  8. // Set font to arial, bold, 14pt
  9. $pdf->SetFont('Arial','B',14);
  10. $pdf->Cell(130 ,5,'Lexipress.CO',0,0);
  11. $pdf->Cell(59 ,5,'INVOICE',0,1);//end of line
  12. // Set font to arial, regular, 12pt
  13. $pdf->SetFont('Arial','',12);
  14. $pdf->Cell(130 ,5,'[Street Address]',0,0);
  15. $pdf->Cell(59 ,5,'',0,1);//end of line
  16. $pdf->Cell(130 ,5,'[City, Country, ZIP]',0,0);
  17. $pdf->Cell(25 ,5,'Date',0,0);
  18. $pdf->Cell(34 ,5,'[dd/mm/yyyy]',0,1);//end of line
  19. $pdf->Cell(130 ,5,'Phone [+12345678]',0,0);
  20. $pdf->Cell(25 ,5,'Invoice #',0,0);
  21. $pdf->Cell(34 ,5,'[1234567]',0,1);//end of line
  22. $pdf->Cell(130 ,5,'Fax [+12345678]',0,0);
  23. $pdf->Cell(25 ,5,'Customer ID',0,0);
  24. $pdf->Cell(34 ,5,'[1234567]',0,1);//end of line
  25. // Make a dummy empty cell as a vertical spacer
  26. $pdf->Cell(189 ,10,'',0,1);//end of line
  27. // Billing address
  28. $pdf->Cell(100 ,5,'Bill to',0,1);//end of line
  29. // Add dummy cell at the beginning of each line for indentation
  30. $pdf->Cell(10 ,5,'',0,0);
  31. $pdf->Cell(90 ,5,'[Name]',0,1);
  32. $pdf->Cell(10 ,5,'',0,0);
  33. $pdf->Cell(90 ,5,'[Company Name]',0,1);
  34. $pdf->Cell(10 ,5,'',0,0);
  35. $pdf->Cell(90 ,5,'[Address]',0,1);
  36. $pdf->Cell(10 ,5,'',0,0);
  37. $pdf->Cell(90 ,5,'[Phone]',0,1);
  38. // Make a dummy empty cell as a vertical spacer
  39. $pdf->Cell(189 ,10,'',0,1);//end of line
  40. // Invoice contents
  41. $pdf->SetFont('Arial','B',12);
  42. $pdf->Cell(130 ,5,'Description',1,0);
  43. $pdf->Cell(25 ,5,'Taxable',1,0);
  44. $pdf->Cell(34 ,5,'Amount',1,1);//end of line
  45. $pdf->SetFont('Arial','',12);
  46. // Numbers are right-aligned, so we give 'R' after the new line parameter
  47. $pdf->Cell(130 ,5,'UltraCool Fridge',1,0);
  48. $pdf->Cell(25 ,5,'-',1,0);
  49. $pdf->Cell(34 ,5,'3,250',1,1,'R');//end of line
  50. $pdf->Cell(130 ,5,'Supaclean Dishwasher',1,0);
  51. $pdf->Cell(25 ,5,'-',1,0);
  52. $pdf->Cell(34 ,5,'1,200',1,1,'R');//end of line
  53. $pdf->Cell(130 ,5,'Something Else',1,0);
  54. $pdf->Cell(25 ,5,'-',1,0);
  55. $pdf->Cell(34 ,5,'1,000',1,1,'R');//end of line
  56. // Summary
  57. $pdf->Cell(130 ,5,'',0,0);
  58. $pdf->Cell(25 ,5,'Subtotal',0,0);
  59. $pdf->Cell(4 ,5,'$',1,0);
  60. $pdf->Cell(30 ,5,'4,450',1,1,'R');//end of line
  61. $pdf->Cell(130 ,5,'',0,0);
  62. $pdf->Cell(25 ,5,'Taxable',0,0);
  63. $pdf->Cell(4 ,5,'$',1,0);
  64. $pdf->Cell(30 ,5,'0',1,1,'R');//end of line
  65. $pdf->Cell(130 ,5,'',0,0);
  66. $pdf->Cell(25 ,5,'Tax Rate',0,0);
  67. $pdf->Cell(4 ,5,'$',1,0);
  68. $pdf->Cell(30 ,5,'10%',1,1,'R');//end of line
  69. $pdf->Cell(130 ,5,'',0,0);
  70. $pdf->Cell(25 ,5,'Total Due',0,0);
  71. $pdf->Cell(4 ,5,'$',1,0);
  72. $pdf->Cell(30 ,5,'4,450',1,1,'R');//end of line
  73. $pdf->Output();
  74. ?>

I hope this helps you format your invoices as you described. If you have further questions or need assistance with specific parts of your code, feel free to ask.

英文:

I am facing a problem of getting the the data for a specific id. I want the user to get the link to download the data from a button. This is mysqldatatable name (add_courier):

id | order_inv | name | date | quantity of the items | price | payment mode.

Now, I am able to get the list of all the ids but I am not able to get the invoice for a specific id. Here is my code:

  1. &lt;?php
  2. require(&#39;fpdf.php&#39;);
  3. $con=mysqli_connect(&#39;localhost&#39;,&#39;root&#39;,&#39;&#39;);
  4. mysqli_select_db($con,&#39;lexipressdb&#39;);
  5. class PDF extends FPDF {
  6. function Header(){
  7. $this-&gt;SetFont(&#39;Arial&#39;,&#39;B&#39;,15);
  8. //dummy cell to put logo
  9. //$this-&gt;Cell(12,0,&#39;&#39;,0,0);
  10. //is equivalent to:
  11. $this-&gt;Cell(12);
  12. //put logo
  13. $this-&gt;Image(&#39;gift.jpg&#39;,10,10,10);
  14. $this-&gt;Cell(100,10,&#39;Invoice&#39;,0,1);
  15. //dummy cell to give line spacing
  16. //$this-&gt;Cell(0,5,&#39;&#39;,0,1);
  17. //is equivalent to:
  18. $this-&gt;Ln(5);
  19. $this-&gt;SetFont(&#39;Arial&#39;,&#39;B&#39;,11);
  20. $this-&gt;SetFillColor(180,180,255);
  21. $this-&gt;SetDrawColor(180,180,255);
  22. $this-&gt;Cell(40,5,&#39;Order Invoice&#39;,1,0,&#39;&#39;,true);
  23. $this-&gt;Cell(25,5,&#39;Quantity&#39;,1,0,&#39;&#39;,true);
  24. $this-&gt;Cell(65,5,&#39;Weight&#39;,1,0,&#39;&#39;,true);
  25. $this-&gt;Cell(60,5,&#39;Cost&#39;,1,1,&#39;&#39;,true);
  26. }
  27. function Footer(){
  28. //add table&#39;s bottom line
  29. $this-&gt;Cell(190,0,&#39;&#39;,&#39;T&#39;,1,&#39;&#39;,true);
  30. //Go to 1.5 cm from bottom
  31. $this-&gt;SetY(-15);
  32. $this-&gt;SetFont(&#39;Arial&#39;,&#39;&#39;,8);
  33. //width = 0 means the cell is extended up to the right margin
  34. $this-&gt;Cell(0,10,&#39;Page &#39;.$this-&gt;PageNo().&quot; / {pages}&quot;,0,0,&#39;C&#39;);
  35. }
  36. }
  37. //A4 width : 219mm
  38. //default margin : 10mm each side
  39. //writable horizontal : 219-(10*2)=189mm
  40. $pdf = new PDF(&#39;P&#39;,&#39;mm&#39;,&#39;A4&#39;); //use new class
  41. //define new alias for total page numbers
  42. $pdf-&gt;AliasNbPages(&#39;{pages}&#39;);
  43. $pdf-&gt;SetAutoPageBreak(true,15);
  44. $pdf-&gt;AddPage();
  45. $pdf-&gt;SetFont(&#39;Arial&#39;,&#39;&#39;,9);
  46. $pdf-&gt;SetDrawColor(180,180,255);
  47. $query=mysqli_query($con,&quot;select * from add_courier&quot;);
  48. while($data=mysqli_fetch_array($query)){
  49. $pdf-&gt;Cell(40,5,$data[&#39;order_inv&#39;],&#39;LR&#39;,0);
  50. $pdf-&gt;Cell(25,5,$data[&#39;r_qnty&#39;],&#39;LR&#39;,0);
  51. $pdf-&gt;Cell(60,5,$data[&#39;r_weight&#39;],&#39;LR&#39;,0);
  52. $pdf-&gt;Cell(60,5,$data[&#39;r_costtotal&#39;],&#39;LR&#39;,1);
  53. }
  54. $pdf-&gt;Output();
  55. ?&gt;

I want to have my format to be like this for each id so that the user can download it from the link:'

  1. &lt;?php
  2. require(&#39;fpdf.php&#39;);
  3. //A4 width : 219mm
  4. //default margin : 10mm each side
  5. //writable horizontal : 219-(10*2)=189mm
  6. $pdf = new FPDF(&#39;P&#39;,&#39;mm&#39;,&#39;A4&#39;);
  7. $pdf-&gt;AddPage();
  8. //set font to arial, bold, 14pt
  9. $pdf-&gt;SetFont(&#39;Arial&#39;,&#39;B&#39;,14);
  10. //Cell(width , height , text , border , end line , [align] )
  11. $pdf-&gt;Cell(130 ,5,&#39;Lexipress.CO&#39;,0,0);
  12. $pdf-&gt;Cell(59 ,5,&#39;INVOICE&#39;,0,1);//end of line
  13. //set font to arial, regular, 12pt
  14. $pdf-&gt;SetFont(&#39;Arial&#39;,&#39;&#39;,12);
  15. $pdf-&gt;Cell(130 ,5,&#39;[Street Address]&#39;,0,0);
  16. $pdf-&gt;Cell(59 ,5,&#39;&#39;,0,1);//end of line
  17. $pdf-&gt;Cell(130 ,5,&#39;[City, Country, ZIP]&#39;,0,0);
  18. $pdf-&gt;Cell(25 ,5,&#39;Date&#39;,0,0);
  19. $pdf-&gt;Cell(34 ,5,&#39;[dd/mm/yyyy]&#39;,0,1);//end of line
  20. $pdf-&gt;Cell(130 ,5,&#39;Phone [+12345678]&#39;,0,0);
  21. $pdf-&gt;Cell(25 ,5,&#39;Invoice #&#39;,0,0);
  22. $pdf-&gt;Cell(34 ,5,&#39;[1234567]&#39;,0,1);//end of line
  23. $pdf-&gt;Cell(130 ,5,&#39;Fax [+12345678]&#39;,0,0);
  24. $pdf-&gt;Cell(25 ,5,&#39;Customer ID&#39;,0,0);
  25. $pdf-&gt;Cell(34 ,5,&#39;[1234567]&#39;,0,1);//end of line
  26. //make a dummy empty cell as a vertical spacer
  27. $pdf-&gt;Cell(189 ,10,&#39;&#39;,0,1);//end of line
  28. //billing address
  29. $pdf-&gt;Cell(100 ,5,&#39;Bill to&#39;,0,1);//end of line
  30. //add dummy cell at beginning of each line for indentation
  31. $pdf-&gt;Cell(10 ,5,&#39;&#39;,0,0);
  32. $pdf-&gt;Cell(90 ,5,&#39;[Name]&#39;,0,1);
  33. $pdf-&gt;Cell(10 ,5,&#39;&#39;,0,0);
  34. $pdf-&gt;Cell(90 ,5,&#39;[Company Name]&#39;,0,1);
  35. $pdf-&gt;Cell(10 ,5,&#39;&#39;,0,0);
  36. $pdf-&gt;Cell(90 ,5,&#39;[Address]&#39;,0,1);
  37. $pdf-&gt;Cell(10 ,5,&#39;&#39;,0,0);
  38. $pdf-&gt;Cell(90 ,5,&#39;[Phone]&#39;,0,1);
  39. //make a dummy empty cell as a vertical spacer
  40. $pdf-&gt;Cell(189 ,10,&#39;&#39;,0,1);//end of line
  41. //invoice contents
  42. $pdf-&gt;SetFont(&#39;Arial&#39;,&#39;B&#39;,12);
  43. $pdf-&gt;Cell(130 ,5,&#39;Description&#39;,1,0);
  44. $pdf-&gt;Cell(25 ,5,&#39;Taxable&#39;,1,0);
  45. $pdf-&gt;Cell(34 ,5,&#39;Amount&#39;,1,1);//end of line
  46. $pdf-&gt;SetFont(&#39;Arial&#39;,&#39;&#39;,12);
  47. //Numbers are right-aligned so we give &#39;R&#39; after new line parameter
  48. $pdf-&gt;Cell(130 ,5,&#39;UltraCool Fridge&#39;,1,0);
  49. $pdf-&gt;Cell(25 ,5,&#39;-&#39;,1,0);
  50. $pdf-&gt;Cell(34 ,5,&#39;3,250&#39;,1,1,&#39;R&#39;);//end of line
  51. $pdf-&gt;Cell(130 ,5,&#39;Supaclean Diswasher&#39;,1,0);
  52. $pdf-&gt;Cell(25 ,5,&#39;-&#39;,1,0);
  53. $pdf-&gt;Cell(34 ,5,&#39;1,200&#39;,1,1,&#39;R&#39;);//end of line
  54. $pdf-&gt;Cell(130 ,5,&#39;Something Else&#39;,1,0);
  55. $pdf-&gt;Cell(25 ,5,&#39;-&#39;,1,0);
  56. $pdf-&gt;Cell(34 ,5,&#39;1,000&#39;,1,1,&#39;R&#39;);//end of line
  57. //summary
  58. $pdf-&gt;Cell(130 ,5,&#39;&#39;,0,0);
  59. $pdf-&gt;Cell(25 ,5,&#39;Subtotal&#39;,0,0);
  60. $pdf-&gt;Cell(4 ,5,&#39;$&#39;,1,0);
  61. $pdf-&gt;Cell(30 ,5,&#39;4,450&#39;,1,1,&#39;R&#39;);//end of line
  62. $pdf-&gt;Cell(130 ,5,&#39;&#39;,0,0);
  63. $pdf-&gt;Cell(25 ,5,&#39;Taxable&#39;,0,0);
  64. $pdf-&gt;Cell(4 ,5,&#39;$&#39;,1,0);
  65. $pdf-&gt;Cell(30 ,5,&#39;0&#39;,1,1,&#39;R&#39;);//end of line
  66. $pdf-&gt;Cell(130 ,5,&#39;&#39;,0,0);
  67. $pdf-&gt;Cell(25 ,5,&#39;Tax Rate&#39;,0,0);
  68. $pdf-&gt;Cell(4 ,5,&#39;$&#39;,1,0);
  69. $pdf-&gt;Cell(30 ,5,&#39;10%&#39;,1,1,&#39;R&#39;);//end of line
  70. $pdf-&gt;Cell(130 ,5,&#39;&#39;,0,0);
  71. $pdf-&gt;Cell(25 ,5,&#39;Total Due&#39;,0,0);
  72. $pdf-&gt;Cell(4 ,5,&#39;$&#39;,1,0);
  73. $pdf-&gt;Cell(30 ,5,&#39;4,450&#39;,1,1,&#39;R&#39;);//end of line
  74. $pdf-&gt;Output();
  75. ?&gt;

I don't know how to go about it. Can someone please help? I've also checked the other questions for the same issues but i'm not getting the resloution.'

答案1

得分: 1

Here is the translated code:

  1. $sql = mysqli_query($con, "select * from add_courier");
  2. foreach loop starts here
  3. <button><a href="printme.php&id=<?php echo $row['id']; ?>">Print</a></button>
  4. foreach loop ends here
  5. In your FPDF page, get the ID variable
  6. // Example
  7. require('fpdf.php');
  8. $con = mysqli_connect('localhost', 'root', '');
  9. mysqli_select_db($con, 'lexipressdb');
  10. $id = $_GET['id'];
  11. Alter your query with this on the FPDF page
  12. $query = mysqli_query($con, "select * from add_courier where id='$id'");
英文:
  1. $sql=mysqli_query($con,&quot;select * from add_courier&quot;);
  2. foreach loop starts here
  3. &lt;button &gt; &lt;a href=&quot;printme.php&amp;id=&lt;?php echo $row[&#39;id&#39;]?&gt;&quot;&gt;Print&lt;/a&gt;
  4. &lt;/button&gt;

for each loop ends here

in your FPDF page get the ID variable

//example//

  1. require(&#39;fpdf.php&#39;);
  2. $con=mysqli_connect(&#39;localhost&#39;,&#39;root&#39;,&#39;&#39;);
  3. mysqli_select_db($con,&#39;lexipressdb&#39;);
  4. $id=$_GET[&#39;id&#39;];

alter your query with this on FPDF page

  1. $query=mysqli_query($con,&quot;select * from add_courier where id=&#39;$id&#39;&quot;);

答案2

得分: 1

以下是您提供的代码的翻译:

  1. <table>
  2. <thead>
  3. <th style="font-weight:bold;">追踪</th>
  4. <th style="font-weight:bold;">打印发票</th>
  5. </thead>
  6. <tbody>
  7. <?php
  8. $ret = mysqli_query($con, "select * from add_courier");
  9. $cnt = 1;
  10. while ($row = mysqli_fetch_array($ret)) {
  11. ?>
  12. <tr>
  13. <td style="font-weight:bold;"><?php echo $row['trackingid']; ?></td>
  14. <td>
  15. <a href="invoice/generate_pdf.php?id=<?php echo $row['trackingid']; ?>">生成</a>
  16. </td>
  17. </tr>
  18. <?php
  19. }
  20. ?>
  21. </tbody>
  22. </table>
  1. <?php
  2. require('fpdf.php');
  3. $con = mysqli_connect('localhost', 'root', '');
  4. mysqli_select_db($con, 'lexipressdb');
  5. $id = $_GET['id'];
  6. // 请首先回显并检查id的值
  7. echo $id;
  8. exit;
  9. // 如果在点击生成链接时获取到id值,则注释掉上面的行并享受
  10. class PDF extends FPDF
  11. {
  12. function Header()
  13. {
  14. $this->SetFont('Arial', 'B', 15);
  15. // 用于放置标志的虚拟单元格
  16. // $this->Cell(12, 0, '', 0, 0);
  17. // 等同于:
  18. $this->Cell(12);
  19. // 放置标志
  20. $this->Image('gift.jpg', 10, 10, 10);
  21. $this->Cell(100, 10, '发票', 0, 1);
  22. // 用于给出行间距的虚拟单元格
  23. // $this->Cell(0, 5, '', 0, 1);
  24. // 等同于:
  25. $this->Ln(5);
  26. $this->SetFont('Arial', 'B', 11);
  27. $this->SetFillColor(180, 180, 255);
  28. $this->SetDrawColor(180, 180, 255);
  29. $this->Cell(40, 5, '订单发票', 1, 0, '', true);
  30. $this->Cell(25, 5, '数量', 1, 0, '', true);
  31. $this->Cell(65, 5, '重量', 1, 0, '', true);
  32. $this->Cell(60, 5, '成本', 1, 1, '', true);
  33. }
  34. function Footer()
  35. {
  36. // 添加表的底边线
  37. $this->Cell(190, 0, '', 'T', 1, '', true);
  38. // 转到底部距离底部1.5厘米的位置
  39. $this->SetY(-15);
  40. $this->SetFont('Arial', '', 8);
  41. // 宽度=0表示该单元格向右边距扩展
  42. $this->Cell(0, 10, '页 ' . $this->PageNo() . " / {pages}", 0, 0, 'C');
  43. }
  44. }
  45. // A4宽度:219mm
  46. // 默认边距:每边10mm
  47. // 可写水平:219-(10*2)=189mm
  48. $pdf = new PDF('P', 'mm', 'A4'); // 使用新类
  49. // 定义总页数的新别名
  50. $pdf->AliasNbPages('{pages}');
  51. $pdf->SetAutoPageBreak(true, 15);
  52. $pdf->AddPage();
  53. $pdf->SetFont('Arial', '', 9);
  54. $pdf->SetDrawColor(180, 180, 255);
  55. $query = mysqli_query($con, "select * from add_courier where id='$id'");
  56. while ($data = mysqli_fetch_array($query)) {
  57. $pdf->Cell(40, 5, $data['order_inv'], 'LR', 0);
  58. $pdf->Cell(25, 5, $data['r_qnty'], 'LR', 0);
  59. $pdf->Cell(60, 5, $data['r_weight'], 'LR', 0);
  60. $pdf->Cell(60, 5, $data['r_costtotal'], 'LR', 1);
  61. }
  62. $pdf->Output();
  63. ?>

请注意,这些翻译是根据您提供的代码内容生成的,不包括代码中的注释。如果需要更多帮助或有其他问题,请随时提出。

英文:
  1. &lt;table&gt;
  2. &lt;thead&gt;
  3. &lt;th style=&quot;font-weight:bold;&quot;&gt;Tracking&lt;/th&gt;
  4. &lt;th style=&quot;font-weight:bold;&quot;&gt;Print Invoice&lt;/th&gt;
  5. &lt;/thead&gt;
  6. &lt;tbody&gt;
  7. &lt;?php
  8. $ret=mysqli_query($con,&quot;select *from add_courier&quot;);
  9. $cnt=1;
  10. while ($row=mysqli_fetch_array($ret)) {
  11. ?&gt;
  12. &lt;tr&gt;
  13. &lt;td style=&quot;font-weight:bold;&quot;&gt;&lt;?php echo $row[&#39;trackingid&#39;];?&gt;
  14. &lt;/td&gt;
  15. &lt;td&gt;
  16. &lt;a href=&quot;invoice/generate_pdf.php?id=&lt;?php echo $row[&#39;trackingid&#39;];
  17. //this is your tracking primary key column name
  18. ?&gt;&quot;&gt;Generate&lt;/a&gt;
  19. &lt;/td&gt;
  20. &lt;/tr&gt;
  21. &lt;?php
  22. }
  23. ?&gt;
  24. &lt;/tbody&gt;
  25. &lt;/table&gt;
  26. --------------------------------------------------------------------------------------------------------

generate_pdf.php code

  1. &lt;?php
  2. require(&#39;fpdf.php&#39;);
  3. $con=mysqli_connect(&#39;localhost&#39;,&#39;root&#39;,&#39;&#39;);
  4. mysqli_select_db($con,&#39;lexipressdb&#39;);
  5. $id=$_GET[&#39;id&#39;];

// please first echo and check the id value

  1. echo $id; exit;

// if you get the id on clicking generate link then comment the above line and enjoy

  1. class PDF extends FPDF {
  2. function Header(){
  3. $this-&gt;SetFont(&#39;Arial&#39;,&#39;B&#39;,15);
  4. //dummy cell to put logo
  5. //$this-&gt;Cell(12,0,&#39;&#39;,0,0);
  6. //is equivalent to:
  7. $this-&gt;Cell(12);
  8. //put logo
  9. $this-&gt;Image(&#39;gift.jpg&#39;,10,10,10);
  10. $this-&gt;Cell(100,10,&#39;Invoice&#39;,0,1);
  11. //dummy cell to give line spacing
  12. //$this-&gt;Cell(0,5,&#39;&#39;,0,1);
  13. //is equivalent to:
  14. $this-&gt;Ln(5);
  15. $this-&gt;SetFont(&#39;Arial&#39;,&#39;B&#39;,11);
  16. $this-&gt;SetFillColor(180,180,255);
  17. $this-&gt;SetDrawColor(180,180,255);
  18. $this-&gt;Cell(40,5,&#39;Order Invoice&#39;,1,0,&#39;&#39;,true);
  19. $this-&gt;Cell(25,5,&#39;Quantity&#39;,1,0,&#39;&#39;,true);
  20. $this-&gt;Cell(65,5,&#39;Weight&#39;,1,0,&#39;&#39;,true);
  21. $this-&gt;Cell(60,5,&#39;Cost&#39;,1,1,&#39;&#39;,true);
  22. }
  23. function Footer(){
  24. //add table&#39;s bottom line
  25. $this-&gt;Cell(190,0,&#39;&#39;,&#39;T&#39;,1,&#39;&#39;,true);
  26. //Go to 1.5 cm from bottom
  27. $this-&gt;SetY(-15);
  28. $this-&gt;SetFont(&#39;Arial&#39;,&#39;&#39;,8);
  29. //width = 0 means the cell is extended up to the right margin
  30. $this-&gt;Cell(0,10,&#39;Page &#39;.$this-&gt;PageNo().&quot; / {pages}&quot;,0,0,&#39;C&#39;);
  31. }
  32. }
  33. //A4 width : 219mm
  34. //default margin : 10mm each side
  35. //writable horizontal : 219-(10*2)=189mm
  36. $pdf = new PDF(&#39;P&#39;,&#39;mm&#39;,&#39;A4&#39;); //use new class
  37. //define new alias for total page numbers
  38. $pdf-&gt;AliasNbPages(&#39;{pages}&#39;);
  39. $pdf-&gt;SetAutoPageBreak(true,15);
  40. $pdf-&gt;AddPage();
  41. $pdf-&gt;SetFont(&#39;Arial&#39;,&#39;&#39;,9);
  42. $pdf-&gt;SetDrawColor(180,180,255);
  43. $query=mysqli_query($con,&quot;select * from add_courier where id=&#39;$id&#39;&quot;);
  44. while($data=mysqli_fetch_array($query)){
  45. $pdf-&gt;Cell(40,5,$data[&#39;order_inv&#39;],&#39;LR&#39;,0);
  46. $pdf-&gt;Cell(25,5,$data[&#39;r_qnty&#39;],&#39;LR&#39;,0);
  47. $pdf-&gt;Cell(60,5,$data[&#39;r_weight&#39;],&#39;LR&#39;,0);
  48. $pdf-&gt;Cell(60,5,$data[&#39;r_costtotal&#39;],&#39;LR&#39;,1);
  49. }
  50. $pdf-&gt;Output();
  51. ?&gt;

huangapple
  • 本文由 发表于 2020年1月6日 16:30:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/59608868.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定