I'd like to catch the word "Bronze" from this html page portion:
<tr class="">
<td align="left" csk="Nikpai,Rohullah">Rohullah Nikpai</td>
<td align="right" >25</td>
<td align="left" >Men's Featherweight</td>
<td align="right" csk="3">3T </td>
<td align="left" class=" Bronze" csk="1"><strong>Bronze</strong></td>
</tr>
I tried different code but I failed in my intent. One of many attempts is the following:
foreach($html4->find('td align="left" strong') as $tag4) {
echo $prova = $tag4->innertext . "\n";
}
where html4 is the entire html page I have to process.
With following Code you can get the classname "Bronze"
<?php
$html='<tr class="">
<td align="left" csk="Nikpai,Rohullah">Rohullah Nikpai</td>
<td align="right" >25</td>
<td align="left" >Mens Featherweight</td>
<td align="right" csk="3">3T </td>
<td align="left" class=" Bronze" csk="1"><strong>Bronze</strong></td>
</tr>';
$dom = new DOMDocument();
#$dom->loadHTML($html);
foreach($dom->getElementsByTagName('td') as $link) {
echo trim($link->getAttribute('class'),' ');
}
?>
Or, if you prefer the Node Value and not the class name and the csk attribut is always 1:
foreach($dom->getElementsByTagName('td') as $link) {
if ($link->getAttribute('csk')=="1"){
echo $link->nodeValue;
}
}
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();
?>
PHP newbie here! I ve been struggling with this for a few days now and i have decided i cant figure this out on my own.
Basically i have 2 database tables "projects_2016" and "attachment".
I want to show the data of "projects_2016" to show in the top table and then check for a matching id number (and if it exsits) in "attachment" it will list all the results under the "project_2016 data".
At the moment it works great but it duplicates the "projects_2016" data for every "attachment" entry.
Here is my code, any input is appreciated!
PS not too concereded about Sql injections. Still learning that!
<?php include '../../../connection_config.php';
$sql = "SELECT DISTINCT * FROM attachment JOIN projects_2016 ON attachment.attachment_ABE_project_number = projects_2016.id ORDER BY `attachment_ABE_project_number` DESC";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
?>
<table width="20" border="1" cellspacing="0" cellpadding="2">
<tr>
<th height="0" scope="col"><table width="990" border="0" align= "center" cellpadding="3" cellspacing="0">
<tr class="text_report">
<td width="107" height="30" align="left" valign="middle" nowrap="nowrap" bgcolor="#F5F5F5"><strong>PNo</strong></td>
<td width="871" align="left" valign="middle" nowrap="nowrap" bgcolor="#F5F5F5"><strong>Project Name</strong></td>
</tr>
<tr>
<td height="20" align="left" valign="middle" bgcolor="#FFFFFF" class="text_report"><strong><?php echo "<br>". $row["ID"]. "<br>";?></strong></td>
<td height="20" align="left" valign="middle" bgcolor= "#FFFFFF" class="text_report"><strong><?php echo "<br>". $row["project_name"]. "<br>";?></strong></td>
</tr>
</table>
<?php
$photo_id = $row["ID"];
$contacts = "SELECT DISTINCT * FROM attachment WHERE attachment_ABE_project_number = '$photo_id'" ;
$result_contacts = $conn->query($contacts);
if ($result_contacts->num_rows > 0) {
// output data of each row
while($row_contacts = $result_contacts->fetch_assoc()) {
?>
<table width="990" border="0" align="center" cellpadding= "3" cellspacing="0" class="text_report">
<tr>
<td height="0" colspan="4" align="left" valign="middle" nowrap="nowrap" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td width="319" height="30" align="left" valign="middle" nowrap="nowrap" bgcolor="#F5F5F5"><strong>File Name</strong></td>
<td width="279" align="left" valign="middle" nowrap="nowrap" bgcolor="#F5F5F5"><strong>File Type</strong></td>
<td width="315" align="left" valign="middle" nowrap="nowrap" bgcolor="#F5F5F5"><strong>File Size (KB)</strong></td>
<td width="53" align="right" valign="middle" nowrap="nowrap" bgcolor="#F5F5F5"><strong>View File</strong></td>
</tr>
<tr>
<td height="20" align="left" valign="middle" bgcolor="#FFFFFF"><?php echo $row_contacts ['file'] ?></td>
<td height="20" align="left" valign="middle" bgcolor="#FFFFFF"><?php echo $row_contacts ['type'] ?></td>
<td height="20" align="left" valign="middle" bgcolor="#FFFFFF"><?php echo $row_contacts ['size'] ?></td>
<td align="right" valign="middle" bgcolor="#FFFFFF">view file</td>
</tr>
<tr>
<td height="0" colspan="4" align="left" valign="middle" bgcolor="#FFFFFF"> </td>
</tr>
<?php
}
?>
</table>
<?php
}
?></th>
</tr>
</table>
<table width="1000" border="0" cellspacing="0" cellpadding="0">
<tr>
<th height="26"> </th>
</tr>
</table>
<p>
<?php
}
}
?>
</p>
</table>
<?php $conn->close();
?>
$sql = "SELECT * FROM projects_2016
WHERE EXISTS (SELECT * FROM attachment WHERE projects_2016.id = attachment_ABE_project_number) ORDER BY id DESC ";
I have been searching through the Internet searching for a solution to my problem. I am currently using CakePhp + dompdf to generate a PDF. It works fine on normal tables, but when I add rowspans and colspans it creates the table but the borders are ruined.
This is my HTML markup for generating the PDF:
<style>table{border-collapse:collapse;}.rows td{border:1px solid brown;</style>
<table class="sub_cat_table">
<tbody><tr class="rows">
<td colspan="2">カテゴリ</td>
<td>重要度</td>
<td>実現度</td>
<td colspan="2">項目(キーワード)</td>
<td colspan="2">重要度</td>
<td colspan="2">実現度</td>
<td colspan="2">格差</td>
</tr>
<tr class="rows">
<td rowspan="2" class="sub_cat_letter"> A </td>
<td rowspan="2" class="sub_cat_name">Situation</td>
<td rowspan="2" class="sub_cat_imp">3.5</td>
<td rowspan="2" class="sub_cat_pos">2.0</td>
</tr>
<tr class="rows">
<td class="sub_cat_number">1</td>
<td class="sub_cat_name">Complete</td>
<td class="sub_cat_imp_inner">3.0</td>
<td class="sub_cat_imp_inner"></td>
<td class="sub_cat_imp_inner">2.0</td>
<td class="sub_cat_imp_inner"> ●</td>
<td class="sub_cat_imp_inner">-1</td>
<td class="sub_cat_imp_inner"></td>
</tr>
<tr class="rows">
<td class="sub_cat_number">2</td>
<td class="sub_cat_name">Access</td>
<td class="sub_cat_imp_inner">4.0</td>
<td class="sub_cat_imp_inner"></td>
<td class="sub_cat_imp_inner">2.0</td>
<td class="sub_cat_imp_inner">● </td>
<td class="sub_cat_imp_inner">-2</td>
<td class="sub_cat_imp_inner"></td>
</tr>
<tr class="rows">
<td rowspan="3" class="sub_cat_letter">B</td>
<td rowspan="3" class="sub_cat_name">Technology</td>
<td rowspan="3" class="sub_cat_imp">3.4</td>
<td rowspan="3" class="sub_cat_pos">1.9</td>
</tr>
<tr class="rows">
<td class="sub_cat_number">3</td>
<td class="sub_cat_name">Quality</td>
<td class="sub_cat_imp_inner">3.7</td>
<td class="sub_cat_imp_inner"></td>
<td class="sub_cat_imp_inner">1.7</td>
<td class="sub_cat_imp_inner"></td>
<td class="sub_cat_imp_inner">-2</td>
<td class="sub_cat_imp_inner">▼ </td>
</tr>
<tr class="rows">
<td class="sub_cat_number">4</td>
<td class="sub_cat_name">Access</td>
<td class="sub_cat_imp_inner">3.0</td>
<td class="sub_cat_imp_inner"></td>
<td class="sub_cat_imp_inner">2.0</td>
<td class="sub_cat_imp_inner">● </td>
<td class="sub_cat_imp_inner">-1</td>
<td class="sub_cat_imp_inner"></td>
</tr>
</tbody>
</table>
Print screen in HTML (sorry, the table has border above):
Print screen in generating PDF in dompdf:
I've been trying to play with the file dompdf/includes/cellmap.cls.php, but I can't get it to work.
I already tried these solutions here:
https://code.google.com/p/dompdf/issues/detail?id=361
https://code.google.com/p/dompdf/issues/detail?id=342
And some links I already forgot. Any advice or workaround is very much appreciated.
I think you don't need to change your dompdf to create PDF, You just need to arrange your table specially the row span rule. When creating a table using row span it should be like this:
<table border="1">
<tr>
<td rowspan="3"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
Its really not much of an "answer" but i suggest switching using tcpdf. I have found it does the best overall job of rendering html to pdf, its also some what easier to customise than other pdf libraries.
code used to generate example:
<?php
// Include the main TCPDF library (search for installation path).
require_once('../tcpdf.php');
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// 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 default font subsetting mode
$pdf->setFontSubsetting(true);
// Set font
// dejavusans is a UTF-8 Unicode font, if you only need to
// print standard ASCII chars, you can use core fonts like
// helvetica or times to reduce file size.
$pdf->SetFont('dejavusans', '', 6, '', true);
// Add a page
// This method has several options, check the source code documentation for more information.
$pdf->AddPage();
// set text shadow effect
//$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));
// Set some content to print
$html = <<<EOD
<style>table{border-collapse:collapse;}.rows td{border:1px solid brown;</style>
<table class="sub_cat_table">
<tbody><tr class="rows">
<td colspan="2">カテゴリ</td>
<td>重要度</td>
<td>実現度</td>
<td colspan="2">項目(キーワード)</td>
<td colspan="2">重要度</td>
<td colspan="2">実現度</td>
<td colspan="2">格差</td>
</tr>
<tr class="rows">
<td rowspan="2" class="sub_cat_letter"> A </td>
<td rowspan="2" class="sub_cat_name">Situation</td>
<td rowspan="2" class="sub_cat_imp">3.5</td>
<td rowspan="2" class="sub_cat_pos">2.0</td>
</tr>
<tr class="rows">
<td class="sub_cat_number">1</td>
<td class="sub_cat_name">Complete</td>
<td class="sub_cat_imp_inner">3.0</td>
<td class="sub_cat_imp_inner"></td>
<td class="sub_cat_imp_inner">2.0</td>
<td class="sub_cat_imp_inner"> ●</td>
<td class="sub_cat_imp_inner">-1</td>
<td class="sub_cat_imp_inner"></td>
</tr>
<tr class="rows">
<td class="sub_cat_number">2</td>
<td class="sub_cat_name">Access</td>
<td class="sub_cat_imp_inner">4.0</td>
<td class="sub_cat_imp_inner"></td>
<td class="sub_cat_imp_inner">2.0</td>
<td class="sub_cat_imp_inner">● </td>
<td class="sub_cat_imp_inner">-2</td>
<td class="sub_cat_imp_inner"></td>
</tr>
<tr class="rows">
<td rowspan="3" class="sub_cat_letter">B</td>
<td rowspan="3" class="sub_cat_name">Technology</td>
<td rowspan="3" class="sub_cat_imp">3.4</td>
<td rowspan="3" class="sub_cat_pos">1.9</td>
</tr>
<tr class="rows">
<td class="sub_cat_number">3</td>
<td class="sub_cat_name">Quality</td>
<td class="sub_cat_imp_inner">3.7</td>
<td class="sub_cat_imp_inner"></td>
<td class="sub_cat_imp_inner">1.7</td>
<td class="sub_cat_imp_inner"></td>
<td class="sub_cat_imp_inner">-2</td>
<td class="sub_cat_imp_inner">▼ </td>
</tr>
<tr class="rows">
<td class="sub_cat_number">4</td>
<td class="sub_cat_name">Access</td>
<td class="sub_cat_imp_inner">3.0</td>
<td class="sub_cat_imp_inner"></td>
<td class="sub_cat_imp_inner">2.0</td>
<td class="sub_cat_imp_inner">● </td>
<td class="sub_cat_imp_inner">-1</td>
<td class="sub_cat_imp_inner"></td>
</tr>
</tbody>
</table>
EOD;
// Print text using writeHTMLCell()
$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
// ---------------------------------------------------------
// Close and output PDF document
// This method has several options, check the source code documentation for more information.
$pdf->Output('example_001.pdf', 'I');
//============================================================+
// END OF FILE
//============================================================+
You just need to use rowspan correctly, you must add the rest of the columns in the same row, here is the code to create the table as you wish.
table {
border-collapse: collapse;
}
.rows td {
border: 1px solid brown;
}
<table class="sub_cat_table">
<tbody>
<tr class="rows">
<td colspan="2">カテゴリ</td>
<td>重要度</td>
<td>実現度</td>
<td colspan="2">項目(キーワード)</td>
<td colspan="2">重要度</td>
<td colspan="2">実現度</td>
<td colspan="2">格差</td>
</tr>
<tr class="rows">
<td rowspan="2" class="sub_cat_letter"> A </td>
<td rowspan="2" class="sub_cat_name">Situation</td>
<td rowspan="2" class="sub_cat_imp">3.5</td>
<td rowspan="2" class="sub_cat_pos">2.0</td>
<td class="sub_cat_number">1</td>
<td class="sub_cat_name">Complete</td>
<td class="sub_cat_imp_inner">3.0</td>
<td class="sub_cat_imp_inner"> </td>
<td class="sub_cat_imp_inner">2.0</td>
<td class="sub_cat_imp_inner"> ●</td>
<td class="sub_cat_imp_inner">-1</td>
<td class="sub_cat_imp_inner"></td>
</tr>
<tr class="rows">
<td class="sub_cat_number">2</td>
<td class="sub_cat_name">Access</td>
<td class="sub_cat_imp_inner">4.0</td>
<td class="sub_cat_imp_inner"> </td>
<td class="sub_cat_imp_inner">2.0</td>
<td class="sub_cat_imp_inner">● </td>
<td class="sub_cat_imp_inner">-2</td>
<td class="sub_cat_imp_inner"></td>
</tr>
<tr class="rows">
<td rowspan="2" class="sub_cat_letter">B</td>
<td rowspan="2" class="sub_cat_name">Technology</td>
<td rowspan="2" class="sub_cat_imp">3.4</td>
<td rowspan="2" class="sub_cat_pos">1.9</td>
<td class="sub_cat_number">3</td>
<td class="sub_cat_name">Quality</td>
<td class="sub_cat_imp_inner">3.7</td>
<td class="sub_cat_imp_inner"> </td>
<td class="sub_cat_imp_inner">1.7</td>
<td class="sub_cat_imp_inner"> </td>
<td class="sub_cat_imp_inner">-2</td>
<td class="sub_cat_imp_inner">▼ </td>
</tr>
<tr class="rows">
<td class="sub_cat_number">4</td>
<td class="sub_cat_name">Access</td>
<td class="sub_cat_imp_inner">3.0</td>
<td class="sub_cat_imp_inner"> </td>
<td class="sub_cat_imp_inner">2.0</td>
<td class="sub_cat_imp_inner">● </td>
<td class="sub_cat_imp_inner">-1</td>
<td class="sub_cat_imp_inner"> </td>
</tr>
</tbody>
</table>
This is the code I am using to display a row in a table:
$msg.='<tr class="'.$outclass.'" onClick="popticket('.$ticket['TicketID'].');" onmouseover="this.className='.$overclass.';" onmouseout="this.className='.$outclass.';" '.$reg1.' '.$reg2.' >
<td width="10%" align="center" class="style28" style="padding: 5px;">'.$ticket['TicketID'].'</td>
<td width="25%" align="left" class="style28">'.substr($ticket['customer_bus_name'], 0, 34).'</td>
<td width="12%" align="center" class="style28">'.$newpr.'</td>
<td width="15%" align="center" class="style28">'.$status.'</td>
<td class="style28">'.strip_tags($ticket['desc']).'</td>
<td width="60px" align="center" class="style28"><span style="display:none;">'.$ticket['updated'].'</span>'.$new_up.'</td>
<td width="45px" align="center" class="style28"><span style="display:none;">'.$ticket['scheduled'].'</span>'.$new_im.'</td>
</tr>';
Here each PHP variable has its own value. The problem is that the class given in the onmouseover and mouseout is not working.
I want to get this row as (this is the correct output):
<tr class="ticketrowsoutread" onmouseout="this.className='ticketrowsoutread';" onmouseover="this.className='ticketrowsover ticketrowsover2';" onclick="popticket('232');">
<td width="10%" align="center" class="style28" style="padding: 5px;">232</td>
<td width="25%" align="left" class="style28">net works</td>
<td width="12%" align="center" class="style28">Medium</td>
<td width="15%" align="center" class="style28">in progress</td>
<td class="style28">adsfasdf</td>
<td width="60px" align="center" class="style28"><span style="display:none;">1334709567</span>1 day</td>
<td width="45px" align="center" class="style28"><span style="display:none;">-</span></td>
</tr>
When I run my code it displays onmouseout="this.className=ticketrowsoutread;" instead of onmouseout="this.className='ticketrowsoutread';".
How can I get the desired output?
Add backslashes to escape the qote
onmouseover="this.className=\''.$overclass.'\';"