Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9083611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:48:55+00:00 2026-06-16T20:48:55+00:00

I just try mPDF to make an output table pdf by database, but it

  • 0

I just try mPDF to make an output table pdf by database, but it still hard to do that.

<?php
$html = '

<center><h3>TITLE</h3></center>
<center>
<table border="1">
<tr>
    <th>COLUMN 1</th><th>COLUMN 2</th>
</tr>
<tr>
        <!--how to fetch this row from DB? -->
    <td>.$row[no1].</td><td>.$row[no2].</td>
</tr>
</table></center>

';
//==============================================================
//==============================================================
//==============================================================
include("../mpdf.php");
    include "conn.php";

    $res = mysql_query("select * from list");
    if (!$res)
        die("query error : ".mysql_error());
$mpdf=new mPDF('c','A4','','',32,25,27,25,16,13);
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list
// LOAD a stylesheet
$stylesheet = file_get_contents('mpdfstyletables.css');
$mpdf->WriteHTML($stylesheet,1); // The parameter 1 tells that this is css/style only and no body/html/text
while($row = mysql_fetch_array($res))
    if (!$res)
        die("error fetch array : ".mysql_error());
$mpdf->WriteHTML($html,2);
$mpdf->Output('mpdf.pdf','I');
exit;
//==============================================================
//==============================================================
//==============================================================
?>

when I run this script, it can generate to PDF but the row didn’t match like the database?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T20:48:56+00:00Added an answer on June 16, 2026 at 8:48 pm

    something like this :

    <?php
    
    //==============================================================
    //==============================================================
    //==============================================================
    include("../mpdf.php");
    include "conn.php";
    
    $res = mysql_query("select * from list");
    if (!$res)
        die("query error : ".mysql_error());
    $mpdf=new mPDF('c','A4','','',32,25,27,25,16,13);
    $mpdf->SetDisplayMode('fullpage');
    $mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list
    // LOAD a stylesheet
    $stylesheet = file_get_contents('mpdfstyletables.css');
    $mpdf->WriteHTML($stylesheet,1); // The parameter 1 tells that this is css/style only and no body/html/text
    $html = '
    
    <center><h3>TITLE</h3></center>
    <center>
    <table border="1">
    <tr>
    <th>COLUMN 1</th><th>COLUMN 2</th>
    </tr>
    <tr>';
    
    while($row = mysql_fetch_array($res)){
    $html .= '<td>'.$row['no1'].'</td><td>' . $row['no2']. '</td>';
    }
    $html .= '</tr>
    </table></center>
    ';
    $mpdf->WriteHTML($html,2); 
    $mpdf->Output('mpdf.pdf','I');
    exit;
    //==============================================================
    //==============================================================
    //==============================================================
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just try putting the jquery-ui theme switcher on my website. Seems that there
I just try to integrate ImageMagick into my PHP project. I installed and just
Just a quick question. I suppose I could just try it but I like
I just try to post data to google by using the following code,but always
I'm looking for Rails plugin that can store image file to database. I've just
I just try install libperl-dev with apt on Ubuntu, but I have following error:
I just try to use JSON for the first time. But my data is
I just try to place a flash file in my site, but I see
Im just try to build a basic class so that I can learn some
i just try to make a simple offline currency converter using 2 spinner. i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.