Problems displaying rowspan in dompdf and cakephp - php
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>
Related
Set While loop in FPDF
This is code is using to generate pdf file. I using $html to do the table and will display in pdf file. But now if insert the while loop in the $html, the output is the php code and got some error. I confusing the single quotes to closing the code. $html='<br><br><br> <table border="1"> <tr> <td bgcolor="#D0D0FF">Product Name</td> <td bgcolor="#D0D0FF">Product Price</td> <td bgcolor="#D0D0FF">Product Quantity</td> <td bgcolor="#D0D0FF">Total Price</td> </tr> //Here </table>` <br> <table border="1"> <tr> <td bgcolor="#D0D0FF">Order Date</td> <td width="600">'.$row['Order_Date'].'</td> </tr> <tr> <td bgcolor="#D0D0FF">Tracking ID</td> <td width="600">'.$row['Tracking_ID'].'</td> </tr> <tr> <td bgcolor="#D0D0FF">Recipient</td> <td width="600">'.$row['Tracking_Recipient'].'</td> </tr> <tr> <td bgcolor="#D0D0FF">Phone Number</td> <td width="600">'.$row['Tracking_PhoneNumber'].'</td> </tr> <tr> <td bgcolor="#D0D0FF">Address</td> <td width="600">'.$row['Tracking_Address'].'</td> </tr> <tr> <td bgcolor="#D0D0FF">Bank</td> <td width="600">'.$row['Bank'].'</td> </tr> </table>'; //While loop
How to get data and set in to php var when use file_get_contents PHP?
How to get data and set in to php var when use file_get_contents PHP ? this is code for http://www.example.com/test.php <table align="center"> <thead style="background-color: #F0F0F0; color: #333333; text-align: center;"> <tr> <th class="countryHeader">Country</th> <th class="intHeader"> </th> <th colspan="2" class="intHeader">Desktop CPM</th> <th colspan="2" class="bannerHeader">Mobile CPM</th> </tr> </thead> <tbody> <tr class="breaker"> <td> </td> <td>Highest</td> <td>Unique</td> <td>Raw</td> <td>Unique</td> <td>Raw</td> </tr> <tr class="odd rateVals"> <td class="countryName">United States</td> <td class="cpmRaw">$2.00</td> <td class="cpm">$3.44</td> <td class="cpmRaw">$2.00</td> <td class="cpmMobile">$1.63</td> <td class="cpmMobileRaw">$0.97</td> </tr> <tr class="even rateVals"> <td class="countryName">Canada</td> <td class="cpmRaw">$1.20</td> <td class="cpm">$2.52</td> <td class="cpmRaw">$1.20</td> <td class="cpmMobile">$1.88</td> <td class="cpmMobileRaw">$1.06</td> </tr> <tr class="odd rateVals"> <td class="countryName">United Kingdom</td> <td class="cpmRaw">$1.60</td> <td class="cpm">$2.10</td> <td class="cpmRaw">$1.08</td> <td class="cpmMobile">$1.71</td> <td class="cpmMobileRaw">$0.94</td> </tr> <tr class="even rateVals"> <td class="countryName">Australia</td> <td class="cpmRaw">$1.50</td> <td class="cpm">$2.62</td> <td class="cpmRaw">$1.20</td> <td class="cpmMobile">$2.73</td> <td class="cpmMobileRaw">$1.49</td> </tr> <tr class="breaker"> <td colspan="6"> </td> </tr> <tr class="odd rateVals"> <td class="countryName">United Arab Emirates</td> <td class="cpmRaw">$1.48</td> <td class="cpm">$2.49</td> <td class="cpmRaw">$1.45</td> <td class="cpmMobile">$2.11</td> <td class="cpmMobileRaw">$1.42</td> </tr> <tr class="odd rateVals"> <td>All other countries</td> <td>-</td> <td colspan="2">$0.25 - $2.00</td> <td colspan="2">$0.06 - $0.22</td> </tr> </tbody> </table> And this is code for my_code.php <?php $test = file_get_contents('http://www.example.com/test.php'); //echo $test; ?> And i want to get php var from column Mobile CPM raw value like this $United_States = "0.97"; $Canada = "1.07"; $United_Kingdom = "0.94"; $Australia = "1.49"; $United_Arab_Emirates = "1.42"; How can i do ?
If you want to parse a HTML document you should use PHP's DOMDocument. Instead of file_get_contents() you should use loadHTMLFile(). Because you are using CSS-classes you should view this post on how to find elements via class.
HTML CSS PHP, Table design
i have a problem to create table like this image in website, can anyone help me to solve that?. blue line in picture. i just don't know how to create table like this image. especially reference no, it has custom border line. Here is table design you can check my code here too MY CODE this is my code <html xmlns="http://www.w3.org/1999/ifxhtml"> <head profile="http://www.w3.org/2005/10/profile"> <title>Glisten - A free web template</title> </head> <body> <table width="800" border="1" align="center"> <tbody> <tr> <td colspan="2" align="center" bgcolor=""><table width="800" border="1" align="center"> <tbody> <tr> <td width="125">Reference No</td> <td colspan="4"> </td> <td colspan="2" bgcolor="#8B8A8A" align="center"></td> </tr> <tr> <td align="center" bgcolor="#FF0004"><strong>NG TINEM</strong></td> </tr> <tr> <td>Site ID</td> <td colspan="3" align="center"></td> <td width="185">BSC Name</td> <td colspan="2" align="center"></td> </tr> <tr> <td>Site Name</td> <td colspan="3" align="center"></td> <td>New Site ID</td> <td colspan="2" align="center"></td> </tr> <tr> <td>Sales Cluster</td> <td colspan="3" align="center"></td> <td>LAC</td> <td colspan="2" align="center"></td> </tr> <tr> <td>Ne Type</td> <td colspan="3" align="center"></td> <td>Config</td> <td colspan="2" align="center"></td> </tr> <tr> <td>Band</td> <td colspan="3" align="center"></td> <td>PO Number</td> <td colspan="2" align="center"></td> </tr> <tr> <td>Cell ID</td> <td width="80" align="center"></td> <td width="82" align="center"></td> <td width="80" align="center"></td> <td> </td> <td colspan="2"> </td> </tr> <tr> <td colspan="7" > </td> </tr> <tr> <td align="center">Integration Date</td> <td align="center"></td> <td align="center">On Air Date</td> <td align="center"></td> <td align="center">Acceptance Date</td> <td colspan="2" align="center"></td> </tr> <tr> </tbody> </table> </body></html>
First identify the total columns to be created. Then use attribute of table like "colspan" to span the columns.
Add following style to your table (I have added class table in your second table tag): <style type="text/css"> .table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th { padding: 8px; line-height: 1.42857143; vertical-align: top; } table { border-collapse: collapse; border-spacing: 0; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; } </style> <table width="800" align="center"> <tbody> <tr> <td colspan="2" align="center" bgcolor=""><table class="table" width="800" border="1" align="center"> <tbody> <?php while($data = mysql_fetch_array($query)){ if($data['dt_report']=='Yes'){ $check_dt_report='checked="checked"'; } else{ $check_dt_report=''; }if($data['kpi_stats']=='Yes'){ $check_kpi_stats='checked="checked"'; } else{ $check_kpi_stats=''; } if($data['clear_alarm']=='Yes'){ $check_clear_alarm='checked="checked"'; } else{ $check_clear_alarm=''; } if($data['configuration']=='Yes'){ $check_configuration='checked="checked"'; } else{ $check_configuration=''; } if($data['neighbor']=='Yes'){ $check_neighbor='checked="checked"'; } else{ $check_neighbor=''; } ?> <tr> <td width="125">Reference No</td> <td colspan="4"> </td> <td colspan="2" bgcolor="#8B8A8A" align="center"><?php echo $data['no_ref']; ?></td> </tr> <tr> <td align="center" bgcolor="#FF0004"><strong>NG TINEM</strong></td> </tr> <tr> <td>Site ID</td> <td colspan="3" align="center"><?php echo $data['site_id']; ?></td> <td width="185">BSC Name</td> <td colspan="2" align="center"><?php echo $data['bsc_name']; ?></td> </tr> <tr> <td>Site Name</td> <td colspan="3" align="center"><?php echo $data['site_name']; ?></td> <td>New Site ID</td> <td colspan="2" align="center"><?php echo $data['new_site_id']; ?></td> </tr> <tr> <td>Sales Cluster</td> <td colspan="3" align="center"><?php echo $data['sales_cluster']; ?></td> <td>LAC</td> <td colspan="2" align="center"><?php echo $data['lac']; ?></td> </tr> <tr> <td>Ne Type</td> <td colspan="3" align="center"><?php echo $data['ne_type']; ?></td> <td>Config</td> <td colspan="2" align="center"><?php echo $data['config']; ?></td> </tr> <tr> <td>Band</td> <td colspan="3" align="center"><?php echo $data['band']; ?></td> <td>PO Number</td> <td colspan="2" align="center"><?php echo $data['po_number']; ?></td> </tr> <tr> <td>Cell ID</td> <td width="80" align="center"><?php echo $data['cell_id1']; ?></td> <td width="82" align="center"><?php echo $data['cell_id2']; ?></td> <td width="80" align="center"><?php echo $data['cell_id3']; ?></td> <td> </td> <td colspan="2"> </td> </tr> <tr> <td colspan="7" > </td> </tr> </tbody> </table>
How to make right border table tcpdf smaller?
I try to create tcpdf using writeHTML like this $pdf->writeHTML($html, true, 0, false, 0); which $html value like code below <table border="1"> <tr> <td width="100%" colspan="4"> <table border="0"> <tr> <td width="18%" style="border-right:0.01px">Test 1</td> <td width="12%">Test 2</td> <td width="20%">Test 3</td> </tr> <tr> <td width="18%" style="border-right:0.01px">Test 4</td> <td width="12%">Test 5</td> <td width="20%">Test 6</td> </tr> </table> </td> </tr> </table> style="border-right:0.01px" or style="border-right:0.1px" or style="border-right:1px" provide same result of border width, how to make this right border smaller? because my result rigth border on Test 1 and Test 4 are biggest then outside border.
If you're a little more explicit in your border definition it'll work as you expect. TCPDF's HTML/CSS parser is rather limited so it helps to be as specific as possible with your styling rules and the like. Your code should work with either border-right-width: 0.1px or with the rest of CSS properties for the shorthand of border-right, see the example HTML below and accompanying screenshot of a rendered PDF (zoomed to highlight difference) <table border="1"> <tr> <td width="100%" colspan="4"> <table border="0"> <tr> <!-- This should work --> <td width="18%" style="border-right-width:0.1px;">Test 1</td> <td width="12%">Test 2</td> <td width="20%">Test 3</td> </tr> <tr> <!-- As should this --> <td width="18%" style="border-right:0.1px solid black;">Test 4</td> <td width="12%">Test 5</td> <td width="20%">Test 6</td> </tr> <tr> <!-- However, this does not. --> <td width="18%" style="border-right:0.1px">Test Broken</td> <td width="12%">Test :)</td> <td width="20%">Test :)</td> </tr> </table> </td> </tr> </table> As you can see, it handles the first two definitions as expected with thinner borders.
I use style="border-right-color:white" to hidden right border <td style="border-right-color:white; border-bottom-color:black; border-top-color:black"></td>
How do I extract values from a html page stored as string using curl function
I am using PHP / curl to get a HTML into a string and then i need to extract the following data and then project a graph out of it . The data I want looks like : <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="generator" content= "HTML Tidy for Linux (vers 25 March 2009), see www.w3.org" /> <title></title> </head> <body> <table> <tbody> <tr> <td> <h3>Income</h3> </td> </tr> <tr> <td>Operating income</td> <td class="numericalColumn">22,922.00</td> <td class="numericalColumn">21,507.30</td> <td class="numericalColumn">17,492.60</td> <td class="numericalColumn">13,683.90</td> <td class="numericalColumn">10,227.12</td> </tr> <tr> <td> <h3>Expenses</h3> </td> </tr> <tr> <td>Material consumed</td> <td class="numericalColumn">4,029.40</td> <td class="numericalColumn">3,442.60</td> <td class="numericalColumn">2,952.30</td> <td class="numericalColumn">1,889.00</td> <td class="numericalColumn">1,367.67</td> </tr> <tr> <td>Manufacturing expenses </td> <td class="numericalColumn">2,213.20</td> <td class="numericalColumn">1,841.80</td> <td class="numericalColumn">299.80</td> <td class="numericalColumn">120.50</td> <td class="numericalColumn">1,020.70</td> </tr> <tr> <td>Personnel expenses</td> <td class="numericalColumn">9,062.80</td> <td class="numericalColumn">9,249.80</td> <td class="numericalColumn">7,409.10</td> <td class="numericalColumn">5,768.20</td> <td class="numericalColumn">4,279.03</td> </tr> <tr> <td>Selling expenses</td> <td class="numericalColumn">378.10</td> <td class="numericalColumn">308.40</td> <td class="numericalColumn">532.10</td> <td class="numericalColumn">-</td> <td class="numericalColumn">171.05</td> </tr> <tr> <td>Adminstrative expenses</td> <td class="numericalColumn">1,737.00</td> <td class="numericalColumn">1,906.00</td> <td class="numericalColumn">2,583.70</td> <td class="numericalColumn">2,651.70</td> <td class="numericalColumn">904.78</td> </tr> <tr> <td>Expenses capitalised</td> <td class="numericalColumn">-</td> <td class="numericalColumn">-</td> <td class="numericalColumn">-</td> <td class="numericalColumn">-</td> <td class="numericalColumn">-</td> </tr> <tr> <td>Cost of sales</td> <td class="numericalColumn">17,420.50</td> <td class="numericalColumn">16,748.60</td> <td class="numericalColumn">13,777.00</td> <td class="numericalColumn">10,429.40</td> <td class="numericalColumn">7,743.22</td> </tr> <tr> <td>Operating profit</td> <td class="numericalColumn">5,501.50</td> <td class="numericalColumn">4,758.70</td> <td class="numericalColumn">3,715.60</td> <td class="numericalColumn">3,254.50</td> <td class="numericalColumn">2,483.90</td> </tr> <tr> <td>Other recurring income</td> <td class="numericalColumn">434.20</td> <td class="numericalColumn">468.20</td> <td class="numericalColumn">326.90</td> <td class="numericalColumn">288.70</td> <td class="numericalColumn">113.59</td> </tr> <tr> <td>Adjusted PBDIT</td> <td class="numericalColumn">5,935.70</td> <td class="numericalColumn">5,226.90</td> <td class="numericalColumn">4,042.50</td> <td class="numericalColumn">3,543.20</td> <td class="numericalColumn">2,597.49</td> </tr> <tr> <td>Financial expenses</td> <td class="numericalColumn">108.40</td> <td class="numericalColumn">196.80</td> <td class="numericalColumn">116.80</td> <td class="numericalColumn">7.20</td> <td class="numericalColumn">3.13</td> </tr> <tr> <td>Depreciation </td> <td class="numericalColumn">579.60</td> <td class="numericalColumn">533.60</td> <td class="numericalColumn">456.00</td> <td class="numericalColumn">359.80</td> <td class="numericalColumn">292.26</td> </tr> <tr> <td>Other write offs</td> <td class="numericalColumn">-</td> <td class="numericalColumn">-</td> <td class="numericalColumn">-</td> <td class="numericalColumn">-</td> <td class="numericalColumn">-</td> </tr> <tr> <td>Adjusted PBT</td> <td class="numericalColumn">5,247.70</td> <td class="numericalColumn">4,496.50</td> <td class="numericalColumn">3,469.70</td> <td class="numericalColumn">3,176.20</td> <td class="numericalColumn">2,302.10</td> </tr> <tr> <td>Tax charges </td> <td class="numericalColumn">790.80</td> <td class="numericalColumn">574.10</td> <td class="numericalColumn">406.40</td> <td class="numericalColumn">334.10</td> <td class="numericalColumn">286.10</td> </tr> <tr> <td>Adjusted PAT</td> <td class="numericalColumn">4,456.90</td> <td class="numericalColumn">3,922.40</td> <td class="numericalColumn">3,063.30</td> <td class="numericalColumn">2,842.10</td> <td class="numericalColumn">2,016.00</td> </tr> <tr> <td>Non recurring items</td> <td class="numericalColumn">441.10</td> <td class="numericalColumn">-948.60</td> <td class="numericalColumn">-</td> <td class="numericalColumn">-</td> <td class="numericalColumn">38.33</td> </tr> <tr> <td>Other non cash adjustments</td> <td class="numericalColumn">-</td> <td class="numericalColumn">-</td> <td class="numericalColumn">-</td> <td class="numericalColumn">-</td> <td class="numericalColumn">-33.85</td> </tr> <tr> <td>Reported net profit</td> <td class="numericalColumn">4,898.00</td> <td class="numericalColumn">2,973.80</td> <td class="numericalColumn">3,063.30</td> <td class="numericalColumn">2,842.10</td> <td class="numericalColumn">2,020.48</td> </tr> <tr> <td>Earnigs before appropriation</td> <td class="numericalColumn">4,898.00</td> <td class="numericalColumn">2,973.80</td> <td class="numericalColumn">3,063.30</td> <td class="numericalColumn">2,842.10</td> <td class="numericalColumn">2,020.48</td> </tr> <tr> <td>Equity dividend</td> <td class="numericalColumn">880.90</td> <td class="numericalColumn">586.00</td> <td class="numericalColumn">876.50</td> <td class="numericalColumn">873.70</td> <td class="numericalColumn">712.88</td> </tr> <tr> <td>Preference dividend</td> <td class="numericalColumn">-</td> <td class="numericalColumn">-</td> <td class="numericalColumn">-</td> <td class="numericalColumn">-</td> <td class="numericalColumn">-</td> </tr> <tr> <td>Dividend tax</td> <td class="numericalColumn">128.30</td> <td class="numericalColumn">99.60</td> <td class="numericalColumn">148.90</td> <td class="numericalColumn">126.80</td> <td class="numericalColumn">99.98</td> </tr> <tr> <td>Retained earnings</td> <td class="numericalColumn">3,888.80</td> <td class="numericalColumn">2,288.20</td> <td class="numericalColumn">2,037.90</td> <td class="numericalColumn">1,841.60</td> <td class="numericalColumn">1,207.62</td> </tr> </tbody> </table> </body> </html> I want to extract each value like Manufacturing Data and the values of all the years mentioned in that line. How do I go about this? I found something like preg_match('#<tr><th>(.*)</th> <td><b>price</b></td></tr>#', $content, $match); but that doesn't get the values I want.
If i understood you question well you want something like this to be done. this was written by me so if you need clarifications i'd love to help. cheers !
You can use libraries like PHP Simple HTML DOM Parser to extract data from HTML/XHTML. http://simplehtmldom.sourceforge.net/manual.htm An example: $pageDom = str_get_html( $rawHtmlData ); foreach( $pageDom->find( 'td' ) as $tblElem ) { if( FALSE !== stristr( $tblElem->innertext, 'Manufacturing expenses' ) ) { // Do stuff } }