FPDF html table to display data from mysql - php

I'm new to fpdf and I'm having trouble on how can I display the data based on my input field. In myh input field php file I will put the name,date etc and I have a print button where when I clicked It will automatically print what I inputted in that field. Now I want that to be printed in a table form format. Below is the fpdf file:
<?php
$html = <<<MYTABLE
<table border="1" style="width:90%" title="Leave" cellpadding="5px" align="center">
<tr>
<td rowspan=1 width="70" align:"top-left"><center><b>1. Name:</b></center><br><select name="office_agency"></td>
<td rowspan=1 width="100" colspan="2" align:"top-left"><b>2. ID / Date</b><br> </td>
</tr>
<tr>
......
</tr>
</table>
MYTABLE;
require('pdftable.inc.php');
mysql_connect('localhost','root','');
mysql_select_db('auth');
$p = new PDFTable();
$p->AddPage();
$p->setfont('times','',10);
$p->Cell(5,-5,'APPLICATION FOR LEAVE');
$p->Ln(3);
$p->htmltable($html);
$p->output();
?>
There. how can put the code for fetching the inputted data following the html format or is there any way than this? thanks

Here you cannot use the html table for direct display,you can create the table using the col() syntax for more check this link [here]
http://www.fpdf.org/en/script/script14.php

Related

MYSQL/PHP Where can i insert

Is it possible somehow to color "company_owner" by the code which user_color holds? That when you open select list, for the sample: Richerson, Rick would be colored by the code which user table has user_color.
$q->addQuery('user_id');
$q->addQuery('user_color');
$q->addQuery('CONCAT_WS(", ",contact_last_name,contact_first_name)');
<tr>
<tr>
<td align="right">
<?php echo $AppUI->_('Kompanijos savininkas'); ?>:
</td>
<td>
<?php
echo arraySelect($owners, 'company_owner', 'size="1" class="text"',
((#$obj->company_owner) ? $obj->company_owner : $AppUI->user_id));
?>
</td>
</tr>
Fetch the content in user_table, register it into a var and parse it in html or in css, don't know how do that in mysqli but if you want I can write it in mysql

Print text inputted in a php form

I put an input text in my form and when I click print it should print in the pdf the text I input in that text field following the table form format. I have a problem on how to catch data from the php file.
PFDF Here is my code:
<?php
$html = <<<MYTABLE
<table border="1" style="width:90%" title="Leave" cellpadding="5px" align="center">
<tr>
<td rowspan=1 width="70" align:"top-left"><center><b>1. Office/Agency</b> </center><br><select name="office_agency"></td>
<td rowspan=1 width="100" colspan="2" align:"top-left"><b>2. ID / Name</b><br> </td>
</tr>
<tr>
<td rowspan=1 align:"top-left"><b>3. Date of Filing:</b><br></td>
<td rowspan=1 align:"top-left"><b>4. Position</b><br></td>
<td rowspan=1 align:"top-left"><b>4. Salary</b><br></td>
..........
MYTABLE;
require('pdftable.inc.php');
mysql_connect('localhost','root','');
mysql_select_db('auth');
$p = new PDFTable();
$p->AddPage();
$p->setfont('times','',10);
$p->Cell(5,-5,' APPLICATION FOR LEAVE');
$p->Ln(3);
$p->htmltable($html);
$p->output();
?>
You need to write the content to the page using Write()
$pdf->Write("content here");
Write Documentation

php simple html dom <tr> bgcolor

ok i've been reading up on simple php html dom and so far it works great.
I have a table which i'm trying to convert to a mysql db.
I'm using this:
foreach($html->find('TR') as $row) {
etc.etc.etc.
}
my table:
<TR BGCOLOR="CCDDFF">
<TD valign="top">
</TD>
</TR>
but how do i get the bgcolor from the tr ?
Did you try the $row->getAttribute('bgcolor') method?

simple_html_dom get an input with a partial id value

Im trying to get td fields from a table with the id sid-120390923 or sid-38737122 ignoring any other id value in the table, however the problem is that I can not get these td fields because they all have a slightly different id but with the same start ('sid').
what I want is to be able to grab all the td fields with the starting id sid-, would there be a way to incorporate regex?
here is an example
html
<table>
<tr>
<td id='9sd'></td>
<td id='10sd'></td>
<td id='sid-1239812983'></td>
<td id='sid-1454345345'></td>
<td id='sid-2342345234'></td>
<td id='sid-5656433455'></td>
<td id='sid-1231235664'></td>
<td id='sid-8986757575'></td>
<td id='sid-1232134551'></td>
</tr>
</table>
simple_html_dom
$table = $con->find('table');
foreach($table->find('td#sid-1232134551') as $field){
echo $field."<br>";
}
You can use attribute filters (the 5. tab),
$table->find('td[id^=sid-]');

Can't display mssql image in a http table using php

I know there are many post about displaying a image from mssql, but they seems dont work in my case if i want it display with other table items.
I can display the binary image indivially by the following code
echo $image=base64_decode($MyBinImg);
then when i wanted to display the image into a table using smarty, it doesnt work
php side:
$smarty->assign("Photo",$image);
$smarty->assign("SomeText","hello world");
tpl side:
<some tags>
..
...
<tr>
<td style="background-color: #d0d0d0;"><b>TEXT</b></td>
<td style="background-color: #f0f0f0;">{$SomeText}</td>
</tr>
<tr>
<td style="background-color: #d0d0d0;"><b>Photo</b></td>
<td style="background-color: #f0f0f0;"><img src="{$Photo}"/></td>
</tr>
The table can display SomeText but not the Photo.
Can someone tell me how to display it.Thanks.
try this:
<img src="data:image/jpeg;base64,/{$Photo}"/>

Categories