how to automatically add a second page in mpdf? - php

I want to convert html file into pdf using mpdf class. working well but the count > 30 the page rotating no display ,
<?php
include("connection.php");
$phase=mysql_query("select * from session where status=1");
$phasee = mysql_fetch_array($phase);
$mindate = $phasee['st_date'];
$maxdate = $phasee['end_date'];
$query_omr = mysql_query("SELECT * from sit_details a,staff_details b where b.staff_code=a.staff_code and a.val_center=".$_GET['num']);
$staffrowdet = mysql_fetch_array($query_omr);
$query_exam_session = mysql_query("SELECT * from exam_session");
$row_exam_session = mysql_fetch_array($query_exam_session);
$randm=rand(100001,999999);
$text_page='
<style>
table {
width:1000px;
font-family:Times New Roman, Times;
border-collapse: collapse;
text-align:justify;
padding:2px;
font-size:12px;
text-transform: uppercase;
}
td, th {
height:30px;
text-transform: uppercase;
padding:2px;
}
</style>
<table id="simple-table" >
<tr><td colspan="2">
<table>
<tr>
<td rowspan="3"><img src="assets/images/logo.gif" width="80px" /></td>
<td align="center" style="font-size:20px"><strong>Heading1 </strong></td>
</tr>
<tr>
<td align="center" style="font-size:16px"><strong>Heading2 - '. $row_exam_session['session'].' </strong> </td>
</tr>
<tr>
<td align="center" style="font-size:14px"><strong>DETAIL</strong></td>
</tr>
</table>
</td></tr>
<tr><td colspan="2">
<table id="dynamic-table" class="table table-striped table-bordered table-hover" width="900" align="left">
<tr>
<th colspan="6" style="font-size:14px" align="left">PERIOD : FROM <u>'.$mindate .' </u> TO <u>'.$maxdate.' </u> </th>
</tr>
<div style="width:50px;height:50px;border:1px solid #000;"></div>
</table>
</td></tr>
<tr>
<td>
<strong><caption> Form Details</caption> </strong>
<table id="dynamic-table" class="table table-striped table-bordered table-hover" border="1" style="page-break-inside: avoid"> <tr bgcolor="#CCCCCC" >
<th align="center" width="50px"><label class="control-label bolder blue">Sl.No </label></th>
<th align="center" width="100px"><label class="control-label bolder blue">Staff ID </label></th>
<th align="left" width="100px"><label class="control-label bolder blue"> Staff Name</label></th>
<th align="left" width="100px"><label class="control-label bolder blue"> Designation </label></th>
</tr>';
$c1=0;
while($row_dummy = mysql_fetch_array($query_omr)) {
$text_page=$text_page.'
<tr>
<td align="center"><h3>'. $c1 .'</h3></td>
<td align="center"><h3>'. $row_dummy['staff_code'].'</h3></td>
<td align="left"><h3>'. $row_dummy['staff_name'].'</h3></td>
<td align="left"><h3>'. $row_dummy['staff_designation'].'</h3></td>
</tr>';
$c1++;
}
$text_page=$text_page.'
<tr>
<table >
</tr>
</table>
</table>
</td>
</tr>
<table id="dynamic-table" class="table table-striped table-bordered table-hover" border="1" width="800" >
<tbody>
<tr>
<th align="center" width="300px" ></th> <br/>
<th align="center" width="150px">Post Held</th>
<th align="center" width="250px">Name</th>
<th align="center" width="50px">Signature</th>
</tr>
<tr>
<td> </td>
<td align="center" height="70"><strong> <br/> Officer / <br/> Coordinator </strong> </td>
<td height="70"></td>
</tr>
<tbody>
<td align="right" width="300px" valign="bottom" rowspan="2" > </td>
</table>
</table>
<table>
<tr><td align="left"><h4>'.$randm.'</h4></td><td align="right"><h4>'.date('d-m-Y H:i:s').'</h4></td></tr>
</table>
';
//echo $text_page;
//exit;
ob_end_clean();
ini_set('memory_limit', '500000M');
include("MPDF57/mpdf.php");
//$mpdf = new mPDF('c', 'A4-L','0', '0', '10', '10','10', '10');
$mpdf = new mPDF(
'', // mode - default ''
'A4', // format - A4, for example, default ''
0, // font size - default 0
'', // default font family
10, // margin_left
10, // margin right
5, // margin top
0, // margin bottom
5, // margin header
5, // margin footer
'P' // L - landscape, P - portrait
);
$mpdf->autoPageBreak = true;
$mpdf->AddPage();
$fname=$_GET['num'].".pdf";
$mpdf->SetWatermarkImage('assets/images/logo.jpg');
$mpdf->setFooter('{PAGENO}');
$mpdf->showWatermarkImage = true;
$mpdf->WriteHTML($text_page);
$mpdf->Output($fname, 'D');
exit;
?>
the pdf downloaded, but the count<30 if the rowcount>30 the page not responding. how to solve this error. i cannot find out the solution. kindly suggest any other mpdf sample program which is matching my requirement.

Related

While creating PDF file,Table alignment between rows not working in TCPDF

Output of the PDF file
I am generating PDF file using TCTDF. I am fetching data from table in TCPDF.
I want to connect the table in flow but I am getting the output like attached image. I am trying but its not working. When I start $htmlcontent without closing the table tag for 2nd code it also showing error. Even CSS is not working for margin between two tables
$htmlcontent ='
<html>
<head>
<meta http-equiv="Content-Language" content="hi">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
td{
height: 8px;
}
</style>
</head>
<body>
<!-- ============================== Logo and address ================================= -->
<table class="table table-hover" border="0" cellpadding="8" cellspacing="0">
<tr>
<td>
<center>
<img src="../assests/images/order_logo.gif" height="75" width="150"/>
</center>
</td>
<td style="text-align:right;">
<p><strong style="font-size: 12px; color:#245580;">SCS Technology</strong><br/>
The Address, Koregaon Park, <br/>
Pune, Maharashtra 411001<br/>
<strong>Mobile: </strong> +91 9988776655<br/>
<strong>Email: </strong> company#domain.com<br/>
</p>
</td>
</tr>
</table>
<p style="border-top: 2px solid #eb8b8b;"></p>
<!-- ============================== Customer name and address ================================= -->
<table class="table table-hover" border="0" cellpadding="8" cellspacing="0">
<tr>
<td style="text-align:left;">
<p><strong style="font-size: 12px; color:#245580;">INVOICE TO:</strong><br/><br/>
<strong style="font-size: 12px;">'.$clientName.'</strong><br/>
<strong>Mobile: </strong> '.$clientContact.'<br/>
</p>
</td>
<td>
<table class="table table-hover" border="0" cellpadding="5" cellspacing="0">
<tr colspan="2">
<th> </th>
<th>Order No : '.$clientName.'</th>
</tr>
<tr colspan="2">
<th> </th>
<th>Invoice Date : '.$orderDate.'</th>
</tr>
<tr colspan="2">
<th> </th>
<th>GST No : APSG6656SRT</th>
</tr>
</table>
</td>
</tr>
</table>
<p style="border-top: 2px solid #eb8b8b;"></p>
<br /><br />
<!-- ============================== Order Information ================================= -->
<table class="table table-hover" border="1" cellpadding="8" cellspacing="0">
<tr>
<th colspan="5" style="text-align:center; background-color:#eb8b8b; font-weight:bold;">Order Details</th>
</tr>
<tr style="text-align:center; background-color:#d9edf7; font-weight:bold;">
<th width="10%">No</th>
<th width="45%">Description</th>
<th width="15%">Price</th>
<th width="15%">Quantity</th>
<th width="15%">Total Price</th>
</tr>
</table>
';
$pdf->writeHTML($htmlcontent, true, false, false, false, '');
$orderItemSql = "SELECT order_item.product_id, order_item.rate, order_item.quantity, order_item.total,
product.product_name FROM order_item
INNER JOIN product ON order_item.product_id = product.product_id
WHERE order_item.order_id = $orderId";
//$orderItemResult = $connect->query($orderItemSql);
$order = mysqli_query($con, $orderItemSql);
$i=0;
while ($orderData1 = mysqli_fetch_array($order)) {
$product_name = $orderData1['product_name'];
$order_quantity = $orderData1['quantity'];
$order_rate = $orderData1['rate'];
$order_total = $orderData1['total'];
$i++;
$htmlcontent ='
<table class="table table-hover" border="1" cellpadding="8" cellspacing="0" style="margin-top:-20px !important;">
<tr>
<td width="10%">'.$i.'</td>
<td width="45%">'.$product_name.'</td>
<td width="15%">'.$order_quantity.'</td>
<td width="15%">'.$order_rate.'</td>
<td width="15%">'.$order_total.'</td>
</tr>
</table>
';
$pdf->writeHTML($htmlcontent, true, false, false, false, '');
}
$htmlcontent ='
<table class="table table-hover" border="1" cellpadding="8" cellspacing="0" style="margin-top:-20px !important;">
<tr>
<td width="85%" style="text-align:right; font-weight:bold;">Sub Total</td>
<td width="15%">'.$subTotal.'</td>
</tr>
<tr>
<td width="85%" style="text-align:right; font-weight:bold;">Discount</td>
<td width="15%">'.$discount.'</td>
</tr>
<tr>
<td width="85%" style="text-align:right; font-weight:bold;">GST 18%</td>
<td width="15%">'.$gstn.'</td>
</tr>
<tr>
<td width="85%" style="text-align:right; font-weight:bold;">Total</td>
<td width="15%">'.$grandTotal.'</td>
</tr>
</table>
<br /><br />
</body>
</html>
<p style="border-top: 2px solid #eb8b8b;"></p>
';
$pdf->writeHTML($htmlcontent, true, false, false, false, '');
//------------------------------------------------------
}
}
The second parameter to writeHTML controls whether a new line should be added. Setting it to false should do the trick:
$pdf->writeHTML($htmlcontent, false, false, false, false, '');
^^^^^

PHP+html webpage to pdf

I am stuck with this thing and don't know what to do.I have googled so many times, and got to know about fpdf,html2pdf,tcpdf.
I am creating an invoice,in which i have used html and php code.I want to display that data in pdf want to convert the whole page to pdf and also print and save it.But I don't know what to do.I am new to this and don't know much.
Have tried some code but I am only getting the html text as output also want php data to.
this is the webpage for invoice.
Code:
index.php
<?php
if(!isset($_POST['submit']))
{
?>
<form method="post" action=''>
<div id="page-wrap">
<textarea id="header" name="text" disabled="disabled">INVOICE</textarea>
<div id="identity">
<textarea name="address" id="address" disabled="disabled" style="background-color:#FFF;color:#000">Address</textarea>
<div id="logo">
<img id="image" src="images/logo.png" alt="logo" /></div>
</div>
<div style="clear:both"></div>
<div id="customer">
<!-- <textarea id="customer-title" disabled="disabled" style="background-color:#FFF;color:#000">Widget Corp.
c/o Steve Widget</textarea>
-->
<table id="meta">
<tr>
<td class="meta-head">Invoice #</td>
<td><textarea>000123</textarea></td>
</tr>
<tr>
<td class="meta-head">Date</td>
<td><textarea id="date"></textarea></td>
</tr>
</table>
</div>
<table id="items">
<tr>
<th>Item</th>
<th>Unit Cost</th>
<th>Quantity</th>
<th>Price</th>
</tr>
<?php
include("./config.php");
$q=0;$u=0;$t=0;$tt=0;$s=0;$v=0;
$sql="SELECT m.order_id,m.table_id,l.item_id,l.order_quantity,i.item_name,i.item_price from order_m m,order_list l,item_list i where m.order_id=l.order_id and l.item_id=i.item_id and table_id=2";
$result=mysqli_query($con,$sql);
while($row=mysqli_fetch_array($result))
{
$q=$q+$row[3];
$u=$u+$row[5];
$t=$t+($row[3]*$row[5]);
?>
<tr class="item-row">
<td class="item-name"><?php echo $row[4]?></td>
<td><?php echo $row[5];?></td>
<td><?php echo $row[3];?></td>
<td><?php echo $row[3]*$row[5];}?></td>
</tr>
<tr>
<td>Total </td>
<td><?php echo $u; ?></td>
<td><?php echo $q;?></td>
<td><?php echo $t;?></td>
</tr>
<?php
$sql1="Select * from tax";
$res=mysqli_query($con,$sql1);
$row1=mysqli_fetch_row($res);
if($row1[0]!=0)
{
$v=($row1[0]*$t)/100;
?>
<tr>
<td> </td>
<td></td>
<td>VAT%</td>
<td><?php echo $row1[0]."%";?></td>
</tr>
<?php
}
else
{
}
if($row1[1]!=0)
{
$s=($row1[1]*$t)/100;
?>
<tr>
<td> </td>
<td></td>
<td>Service Tax.%</td>
<td><?php echo $row1[1]."%";?></td>
</tr>
<?php
}
else
{
}
?>
<tr>
<td></td>
<td></td>
<td>Total</td>
<td><?php $tt=$t+$v+$s; echo round($tt);?></td>
</tr>
</table>
<div id="terms">
<h5>Terms</h5>
<textarea>NET 30 Days. Finance Charge of 1.5% will be made on unpaid balances after 30 days.</textarea>
</div>
</div>
<input type="submit" name="submit" value="Print" />
</form>
<?php
}
else
{
ob_start();
require("html2pdf.php");
$the_file = "./index.php";
$myfile = fopen($the_file, "r") or die("Unable to open file!!!!<br><br><br>");
$homepage = file_get_contents($the_file);
fclose($myfile);
$pdf = new PDF_HTML();
$pdf->AddPage();
$pdf->SetFont('Arial','B',9);
$pdf->WriteHTML($homepage);
$pdf->Output();
ob_end_flush();
exit;
}
?>
Here is the output of the conversion.
you can use tcpdf to render pdf from html. it provides more flexibility
https://tcpdf.org/examples/
see this code, this will generate dummy invoice.
<?php
function generateInvoice(){
$invoice_no = 0001;
require_once('tcpdf/tcpdf.php');
class MYPDF extends TCPDF
{
public function Header() {
}
// Page footer
public function Footer() {
// Position at 15 mm from bottom
$this->SetY(-15);
// Set font
$this->SetFont('helvetica', 'I', 12);
}
}
// create new PDF document
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(0, 0, 0);
$pdf->SetHeaderMargin(0);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(True, 0);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (#file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
// ---------------------------------------------------------
//set custom font
//$fontname = TCPDF_FONTS::addTTFfont('OpenSans-Semibold.ttf', 'TrueTypeUnicode', '',12);
// use the font
$pdf->SetFont($fontname, '', 12, '', false);
// add a page
$pdf->AddPage();
$pdf->setFontSize(40);
$pdf->Write(0, 'Company', '', 0, 'C', true, 0, false, false, 0);
$pdf->setFontSize(12);
$y = $pdf->getY();
$pdf->writeHTMLCell(100, 90, '18', $y+10, '<table cellspacing="0" style="background:#000;" cellpadding="1">
<tr>
<td align="left" columnspan="1" style="font-size:15px" width="80" > Name</td>
<td align="left" style="font-size:15px" width="">name surname</td>
</tr>
<tr>
<td align="left" columnspan="1" style="font-size:15px" width="80" > Address</td>
<td align="left" style="font-size:15px" width="">India</td>
</tr>
<tr>
<td align="left" columnspan="1" style="font-size:15px" width="80" > Mob.</td>
<td align="left" style="font-size:15px" width="">0000000</td>
</tr>
<tr>
<td align="left" columnspan="1" style="font-size:15px" width="80" > Email</td>
<td align="left" style="font-size:15px" width="">johnday#johnday.johnday</td>
</tr>
</table>', 0, 0, 0, false, 'J', true);
$y = $pdf->getY();
$pdf->writeHTMLCell(100, 30, 114, $y, '<table cellspacing="0" style="background:#000;" cellpadding="1">
<tr>
<td align="left" columnspan="1" style="font-size:15px" width="100" > Invoice # :</td>
<td align="left" style="font-size:15px" width="">1000</td>
</tr>
<tr>
<td align="left" columnspan="1" style="font-size:15px" width="100" > Invoice Date</td>
<td align="left" style="font-size:15px" width="">22/02/2016</td>
</tr>
</table>', 0, 0, 0, false, 'J', true);
$y = $pdf->getY();
//$pdf->writeHTMLCell('',10,'',$y+5,$html, 0, 1, 0, true, 'C', true);
$pdf->writeHTML($html, true, false, false, false, '');
$y = $pdf->getY();
$data ='<table cellspacing="0" style="background:#000;" border="1" cellpadding="2">
<thead>
<tr style="background-color:#f2f2f2;">
<th align="center" columnspan="1" style="font-size:15px" width="140" > item</th>
<th align="center" columnspan="1" style="font-size:15px" width="140" > price</th>
<th align="center" columnspan="1" style="font-size:15px" width="140" > quantity</th>
<th align="center" columnspan="1" style="font-size:15px" width="140" > subtotal</th>
<th align="center" columnspan="1" style="font-size:15px" width="140" > total</th>
</tr>
</thead>
<tbody>
<tr style="background-color:#fff;">
<td align="center" columnspan="1" style="font-size:15px" width="140" >book</td>
<td align="center" columnspan="1" style="font-size:15px" width="140" >2</td>
<td align="center" columnspan="1" style="font-size:15px" width="140" >2</td>
<td align="center" columnspan="1" style="font-size:15px" width="140" >4</td>
<td align="center" columnspan="1" style="font-size:15px" width="140" >4</td>
</tr>
<tr><td></td>
<td></td>
<td></td>
<td align="left" columnspan="1" style="font-size:15px" width="140" > Subtotal</td>
<td align="left" style="font-size:13px" width="140">$'. number_format((float) (121), 2, '.', '').'</td>
</tr>
<tr style="background-color:#f2f2f2;">
<td></td>
<td></td>
<td></td>
<td align="left" columnspan="1" style="font-size:15px" width="140" > GST</td>
<td align="left" style="font-size:13px" width="140">included</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td align="left" style="font-size:15px" columnspan="1" width="140"> Discount</td>
<td align="left" style="font-size:13px" width="140">$'.number_format((float) (12121.212), 2, '.', '') .'</td>
</tr>
<tr style="background-color:#f2f2f2;">
<td></td>
<td></td>
<td></td>
<td align="left" style="font-size:15px" columnspan="1" width="140" > Amount Paid</td>
<td align="left" style="font-size:13px" width="140">$'.number_format((float) (1212), 2, '.', '').'</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td align="left" style="font-size:15px" columnspan="1" width="140" > Amount Due</td>
<td align="left" style="font-size:13px" width="140">$'.number_format((float) (1221), 2, '.', '').'</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>';
//$pdf->writeHTMLCell('', '','',$y+8,$data, 0, 1, 0, true, 'C', true);
$pdf->writeHTML($data, true, false, false, false, '');
$y = $pdf->getY();
$pdf->writeHTMLCell('', '', '4',$y+4, '<table cellspacing="0" style="background:#000;" cellpadding="2">
<tr style="background-color:#21B67B;">
<td align="center" style="font-size:20px;color:#fff;" columnspan="0" width="390">PAYMENT METHODS WE ACCEPT</td>
</tr>
<tr>
<td align="left" style="font-size:15px;" width="440">We accept payment by cash, credit card or bank deposit<br></td>
</tr>
<tr>
<td align="left" style="font-size:15px;" width="400">Our Bank Details: </td>
</tr>
<tr>
<td align="left" style="font-size:15px;" width="400">Bank name: demo Bank </td>
</tr><tr>
<td align="left" style="font-size:15px;" width="400">BSB Number: 000000 </td>
</tr><tr>
<td align="left" style="font-size:15px;" width="400">Account Number: 00000 </td>
</tr>
<tr>
<td align="left" style="font-size:15px;" width="400">Account Name: demo demo Ltd </td>
</tr>
<tr>
<td align="left" style="font-size:15px;" width="400"></td>
</tr>
<tr>
<td align="left" style="font-size:15px;" width="400">To make a payment via credit card please call our office on (000) 0000 0000. Cash can be paid on delivery.</td>
</tr>
<tr>
<td align="left" style="font-size:15px;" width="400"></td>
</tr>
<tr>
<td align="center" style="font-size:24px;color:#21B67B;" width="400">Thank you for your business!</td>
</tr>
</table><br<br>', 0, 0, 0, false, 'J', true);
$pdf->lastPage();
$pdf->Output($invoice_no.'.pdf', 'I');
return $invoice_no.'.pdf';
}
generateInvoice();
?>

WriteHTML is not working in mpdf, blank screen displays

I am trying to figure out the problem in this, but not able to. Query is proper, Result i am getting. If i echo $html i get result, but nothing for WriteHTML();
Here is my code
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include("connect.php");
$id = $_GET['id'];
include("mpdf/mpdf.php");
$mpdf=new mPDF('utf-8', 'A4');
$mpdf->debug = true;
$mpdf->useOnlyCoreFonts = true; // false is default
$mpdf->SetProtection(array());
$mpdf->SetTitle("My Company");
$mpdf->SetAuthor("MeAuthor");
$mpdf->SetWatermarkText("Demo");
$mpdf->showWatermarkText = false;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->SetDisplayMode('fullpage');
$s1 = "SELECT * FROM mytable WHERE cid=".$id."";
$sql = mysqli_query($con, $s1) or die (mysqli_error($con));
$row = mysqli_fetch_array($sql);
$html = '
<html>
<head>
<body>
<!--mpdf
<htmlpageheader name="myheader">
<table width="100%"><tr>
<td width="80%" style="text-align: center; font-size: 16pt;">Company Name<br>
<span style="font-size: 11pt;text-align: center;">Address 123, Lorel Ipsum, sdfsdf sdsdgsdg,</span><br>
<span style="font-size: 11pt;text-align:center;">sdfdsfdsf, sfsdf - 100066
</td>
</tr>
</table>
</htmlpageheader>
<sethtmlpageheader name="myheader" value="on" show-this-page="1" />
<sethtmlpagefooter name="myfooter" value="off" />
mpdf-->
<table width="100%">
<tr><td colspan="2" align="right" width="40%"> Vocher No : '.$id.' </td></tr>
<tr>
<td width="70%">Debit A/C. : '.$row['account_no'].' </td>
<td width="30%" style="text-align: right">Date: '.date("d-m-Y").'</td></tr>
</table>
<div style="border: 1px solid black">
<table border="0" style="white-space:nowrap; border-spacing:0;" height="100%" cellspacing="5"><thead>
<tr>
<th width="30%" style="border-right:1px solid #000;">Name</th>
<th width="20%" style="border-right:1px solid #000;">E-Mail</th>
<th width="20%" style="border-right:1px solid #000;">Mobile</th>
<th width="30%" style="border-right:1px solid #000;">Particulars</th>
<th width="15%" style="border-right:1px solid #000;">RS.</th>
<th width="5%" style="border-right:1px solid #000;">P.</th>
</tr>
</thead>
<tr>
<td style="border-right:1px solid #000;" width="30%" height="100px;" >'.$row['name'].'</td>
<td style="border-right:1px solid #000;" width="20%">'.$row['email'].'</td>
<td style="border-right:1px solid #000;" width="20%">'.$row['mobile'].'</td>
<td style="border-right:1px solid #000;" width="30%">'.$row['purpose'].'</td>
<td style="border-right:1px solid #000;" width="15%">'.$row['amount'].'</td>
<td style="border-right:1px solid #000;" width="5%">00</td>
</tr>
<tr><td colspan="4" style="font-weight:bold;">Total Rs.</td> '.$row['amount'].'<td></tr>
</table></div>
<br>
<table border="0"><tr><td style="width=50%;">Mode of Payment : '.$row['mode'].' </td><td width="50%">Date : '.date('Y-m-d').'</td></tr>
<tr><td colspan="2">Rupees : </td></tr>
</table>
<br><br><br>
<table width="100%" border="0">
<tr><td width="20%"> Hon. Secretary </td>
<td width="20%">Hon. Treasurer</td>
<td width="20%">Hon. Trustee</td>
<td width="20%">Receiver s Signature</td></tr>
</table>
</body>
</html>
';
//echo $html;
echo $mpdf->WriteHTML($html);
//$mpdf->Output('Receipt.pdf','D');
$mpdf->Output();
?>
Method WriteHTML() returns void! So you'll not get any echo.
Note that you have not send anything to browser (even http-header) before Output().

How to specify differing column widths for child columns?

I'm creating a table where width of last 3 columns don't change by the values which i set, here is how it looks like in picture:
Programavimo darbas row's last columns size should be one 71 second 11 and last 17. But they are not.
What am i doing wrong, they all are the same even if their sizes are different. Ive tried putting width into style but still the same. Help please! And here is my html code:
<table width="100%" cellspacing="1" cellpadding="4" border="0" class="tbl">
<th style="width: 10%;"><?php echo $AppUI->_('Task type'); ?></th>
<th style="width: 10%;"><?php echo $AppUI->_('Task quantity'); ?></th><!--Užduočių kiekis-->
<th style="width: 10%;"><?php echo $AppUI->_('All time'); ?></th><!--Visas laikas-->
<th style="width: 10%;"><?php echo $AppUI->_('Average'); ?></th><!--Visas laikas-->
<th colspan="3" style="width: 60%;"><?php echo $AppUI->_('In time/Due time'); ?></th><!--Vidurkis per užduotį-->
<?php
if (!empty($taskqu)) {
foreach ($taskqu as $key => $value) {
echo "<tr>";
echo "
<td>{$task_types[$key]}</td>
<td>{$taskqu[$key]['viso_tasku']}</td>
<td>{$taskqu[$key]['viso_valandu']}</td>
<td>{$taskqu[$key]['vidurkis']}</td>
<td style='width: {$taskqu[$key]['viso_pabaigti']}%; background: springgreen; text-align: center;'>comp</td>
<td style='width: {$taskqu[$key]['laiku']}%; background: aquamarine; text-align: center;'>laik</td>
<td style='width: {$taskqu[$key]['veluojama']}%; background: tomato; text-align: center;'>vel</td>";
echo "</tr>";
}
?>
</table>
hIs this what you are trying to achieve with your last few columns?
<table width="100%" border="1">
<thead>
<th style="width:10%;">th1</th>
<th style="width:10%;">th2</th>
<th style="width:10%;">th3</th>
<th style="width:10%;">th4</th>
<th style="width:60%;">th5</th>
</thead>
<tbody>
<tr>
<td>td1</td>
<td>td2</td>
<td>td3</td>
<td>td4</td>
<td>
<table width="100%" border="1" style="background-color:yellow;">
<tr>
<td style="width:71%;">1</td>
<td style="width:11%;">2</td>
<td style="width:17%;">3</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>td1</td>
<td>td2</td>
<td>td3</td>
<td>td4</td>
<td>
<table width="100%" border="1" style="background-color:green;">
<tr>
<td style="width:61%;">1</td>
<td style="width:6%;">2</td>
<td style="width:32%;">3</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>td1</td>
<td>td2</td>
<td>td3</td>
<td>td4</td>
<td>
<table width="100%" border="1" style="background-color:red;">
<tr>
<td style="width:18%;">1</td>
<td style="width:11%;">2</td>
<td style="width:71%;">3</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
There are a few issues that might cause:
There's no <tr> tag after the <table> tag.
You may use <col> tags in the way described below.
Columns
Try using <col> tags:
<table width="100%" cellspacing="1" cellpadding="4" border="0" class="tbl">
<col width="10%">
<col width="10%">
<col width="10%">
<col width="10%">
<col width="60%">
<tr>
<th style="width: 10%;"><?php echo $AppUI->_('Task type'); ?></th>
<th style="width: 10%;"><?php echo $AppUI->_('Task quantity'); ?></th><!--Užduočių kiekis-->
<th style="width: 10%;"><?php echo $AppUI->_('All time'); ?></th><!--Visas laikas-->
<th style="width: 10%;"><?php echo $AppUI->_('Average'); ?></th><!--Visas laikas-->
<th colspan="3" style="width: 60%;"><?php echo $AppUI->_('In time/Due time'); ?></th><!--Vidurkis per užduotį-->
</tr>
<!-- -->
</table>

why my view page doesn't show out data in database mysql

I have successfully created log in and log out page..when the user success to log in using their username and password they will go to the view page but unfortunately the view page doesn't show out data in database mysql and also no error come out on that coding..
This is my viewpage.php
<html>
<?php
include("authenticationStaff.php");
include ("dbase.php");
?>
<body>
<table width="869" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="645" height="50" align="left" valign="middle"><strong>Welcome , You log in as <?php echo $_SESSION['SESS_STAFF_NAME'];?>
<td width="377" align="right" valign="middle"><strong>Log Out</strong></td>
</tr>
</table>
</center>
<?php
$query= "SELECT s.staff_id,s.staff_name,i.project_name,i.location,i.cost,i.pic,i.detail,i.file_name,i.file_type,i.file_size,i.file_content,i.staff_id
FROM staff s
JOIN inter1 i
on(s.staff_id = i.staff_id)
WHERE i.staff_id = '".$_SESSION['SESS_ID']."'";
$result = mysql_query($query);
?>
<tr>
<td colspan="4" align="left" valign="top" class="horizon_divider"><p> </p>
</td><td width="750" valign="top"><div align="center">
<h3>DATA</h3>
<table width="836" border="2" align="center" style= "background-color: #FFFFFF; color: #000000; margin: 0 auto;" >
<thead>
<tr bgcolor="#FFFFFF">
<th width="142">PROJECT NAME</th>
<th width="114">LOCATON</th>
<th width="94">COST</th>
<th width="151">PERSON IN CHARGE</th>
<th width="187">DETAIL</th>
<th width="187">ATTACHMENT</th>
<th width="88">ACTION</th>
</tr>
</thead>
<tbody>
<?php
while( $row = mysql_fetch_assoc( $result ) ){
echo
"<tr>
<td>{$row['project_name']}</td>
<td>{$row['location']}</td>
<td>{$row['cost']}</td>
<td>{$row['pic']}</td>
<td>{$row['detail']}</td>
<td></td>
<td><a href='editStaff.php?id={$row ['staff_id']}'>ADD NEW RECORD</a>||<a href='deleteStaff.php?id={$row ['staff_id']}'>DELETE</a></td> </tr> ";
}
?>
</tbody>
</table>
</table>
</body>
</html>
Can someone see where I am going wrong?if you need any more info then please let me know. thanks.

Categories