Powerhsell + HTMl Formatting - html

I need some help here. I have the below Powershell code which I use to generate a HTML Table with Database Size and Names.
Now the output is good and everything looks better.. But sinew I have got over 500 Databases my boss has to scroll a lot to read the data,
I was thinking if there is a way I can put it in a column.
Something like this
Mbx001 MBX002 MBX003 MBX004
2.1 GB 3.2 GB 4.5 GB 10.8 GB
here is the power shell code
$dbreport = Generate-ReportHeader "dbreport.png" "$l_db_header"
$cells=#("$DB Name","Database Size")
$dbreport += Generate-HTMLTable "Database Overview" $cells
$databases = get-mailboxdatabase -status | sort
$currentDate = Get-Date
foreach ($database in $databases)
{
$dbname = $database.name
$dbserver = $database.server
$dbsize = $database.DatabaseSize
$pf = (Get-MailboxDatabase "$database" | get-mailbox -ResultSize Unlimited).count
$cells=#("$dbname","$dbsize")
$dbreport += New-HTMLTableLine $cells
$dbsizeges = $dbsizeges + $database.databasesize
$gespf = $gespf + $pf
$dbsizegb= $dbsize.Split(' ')[0]
$dbvalues += #{$dbname=$dbsizegb}
}
$dbreport += End-HTMLTable
$cells=#("DatabaseCount","Database Size","Database Overall Count")
$dbreport += Generate-HTMLTable "$l_db_summary" $cells
$anzdb = $databases.count
$cells=#("$anzdb","$dbsizeges","$gespf")
$dbreport += New-HTMLTableLine $cells
$dbreport += End-HTMLTable
new-cylinderchart 500 400 Database Name Size $dbvalues "$tmpdir\dbstat.png"
$dbreport += Include-HTMLInlinePictures "$tmpdir\dbstat.png"
$dbreport | set-content "$tmpdir\dbreport.html"
$dbreport | add-content "$tmpdir\report.html"
Here is the Functions File
#HTML Tables #-------------------------------------------------------------------------------------- # HTML Header function New-HTMLHeader ($title) { $HTMLHeader = "
<html>
<head>
<title>$title</title>
</head>
<body>
<div align=` "center`">
<table style=` "width: 90%; text-align: left; margin-left: auto; margin-right: auto; border-collapse:collapse; font-family:calibri;`" border=` "0`" cellpadding=` "0`" cellspacing=` "0`">
<tr>
<td style=` "background-color: `#0072C6; color: `#ffffff; font-weight: bold; border:solid `#0072C6; border-width: 3px 3px 3px 3px; width: 100px`">
<img src=` "cid:reportheader.png`" alt=` "picture`">
</td>
<td style=` "background-color: `#0072C6; color: `#ffffff; font-weight: bold; border:solid `#0072C6; border-width: 3px 3px 3px 3px; font-size: 20px`">Exchange Report</td>
</tr>
</table>
<table align=` "center`" cellspacing=` "0`" style=` "width: 80%`">
<td style=` "background-color: `#F8F8F8; color: `#585858;`">
Exchange Report for $orgname
<br>Exchange Reporter
<br>
</tr>
</td>
</table>
"#" return $HTMLHeader } # Table function Generate-HTMLTable ($headline, $cells) { $HTMLTable = "
<h3 style=` "text-align:center; font-family:calibri; color: `#0072C6;`">$headline</h3>
<table style=` "width: 80%; text-align: left; margin-left: auto; margin-right: auto; border-collapse:collapse; font-family:calibri;`" border=` "0`" cellpadding=` "0`" cellspacing=` "0`">
<tr>"#" foreach ($cell in $cells) { $HTMLTable += "
<td style=` "background-color: `#0072C6; color: `#ffffff; font-weight: bold; border:solid `#0072C6; border-width: 3px 3px 3px 3px;`">$cell</td>" } $HTMLTable += "</tr>" return $HTMLTable } # New Table function New-HTMLTableLine ($cells) { $NewTableLine = "
<tr>" foreach ($cell in $cells) { $NewTableLine += "
<td style=` "background-color: `#F8F8F8; color: `#585858; border:solid `#0072C6; border-width: 1px 1px 1px 1px;`">$cell</td>" } $NewTableLine += "</tr>" return $NewTableLine } # Table function End-HTMLTable () { $TableEnd = "</table>" return $TableEnd } # HTML End function End-HTML () { $HTMLEnd = "
</body>
</html>
" return $HTMLEnd } # HTML Inline Pictures function Include-HTMLInlinePictures ($picid) { $htmlreport = "
<table align=` "center`" cellspacing=` "0`" style=` "width: 80%`">
<tr>
<td>
<center>
" $Pics = Get-ChildItem "$picid" -name Foreach ($pic in $Pics) { $htmlreport += "
<img src=` "cid:$pic`" alt=` "picture`">" } $htmlreport += "
</center>
</tr>
</td>
</table>
" return $HTMLReport } # Report Header function Generate-ReportHeader ($Image, $Headline) { $ReportHeader = "
<br>" $ReportHeader += "
<table style=` "width: 90%; text-align: left; margin-left: auto; margin-right: auto; border-collapse:collapse; font-family:calibri;`" border=` "0`" cellpadding=` "0`" cellspacing=` "0`">" $ReportHeader += "
<tr>
<td style=` "background-color: `#0072C6; color: `#ffffff; font-weight: bold; border:solid `#0072C6; border-width: 3px 3px 3px 3px; width: 100px`">
<img src=` "cid:$image`" alt=` "picture`">
</td>
<td style=` "background-color: `#0072C6; color: `#ffffff; font-weight: bold; border:solid `#0072C6; border-width: 3px 3px 3px 3px; font-size: 20px`">$headline</td>
</tr>
</table>
" #" return $ReportHeader } # Report Footer function Generate-ReportFooter () { if ($language -match "DE") { $footer = "
<table align=` "center`" cellspacing=` "0`" style=` "width: 80%`">
<tr>
<td style=` "background-color: `#F8F8F8; color: `#585858;`">
Exchange Reporter $reporterversion
<br>
</td>
</tr>
<tr>
<td style=` "background-color: `#F8F8F8; color: `#585858;`">
<center>
<hr>Spenden Sie etwas für die Weiterentwicklung, wenn Ihnen Exchange Reporter gefällt:
<br>
</center>
</td>
</tr>
</table>
"#" return $footer } else { $footer = "
<table align=` "center`" cellspacing=` "0`" style=` "width: 80%`">
<tr>
<td style=` "background-color: `#F8F8F8; color: `#585858;`">
</td>
</tr>
<tr>
<td style=` "background-color: `#F8F8F8; color: `#585858;`">
<center>
<hr>
</center>
</td>
</tr>
</table>
"#" return $footer } }

Related

How to use search option in Powershell HTML output

I want to convert powershell output into HTML format with the search option.
I have HTML with jscript/css which i am trying to add into HTML style in my Powershell code.
The search option is not searching data in page.
HTML code
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box;
}
#myInput {
background-image: url('/css/searchicon.png');
background-position: 10px 10px;
background-repeat: no-repeat;
width: 100%;
font-size: 16px;
padding: 12px 20px 12px 40px;
border: 1px solid #ddd;
margin-bottom: 12px;
}
#myTable {
border-collapse: collapse;
width: 100%;
border: 1px solid #ddd;
font-size: 18px;
}
#myTable th, #myTable td {
text-align: left;
padding: 12px;
}
#myTable tr {
border-bottom: 1px solid #ddd;
}
#myTable tr.header, #myTable tr:hover {
background-color: #f1f1f1;
}
</style>
</head>
<body>
<h2>My Customers</h2>
<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for names.." title="Type in a name">
<table id="myTable">
<tr class="header">
<th style="width:60%;">Name</th>
<th style="width:40%;">Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Germany</td>
</tr>
</table>
<script>
function myFunction() {
var input, filter, table, tr, td, i;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
if (td) {
if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>
</body>
</html>
I want this html format table to get output of command
Get-service.
$services = Get-Service
$FullHTML = $services | select Name,StartType -First 5 | ConvertTo-Html -Fragment
Here's one way to do it:
Replace the entire <table>...</table> section in your HTML with "$table" (no quotes)
Save the code to a text file, say, template.txt
Then you can run the following to produce a searchable HTML page:
$template = Get-Content ".\template.txt" -Raw
$table = (Get-Service | select Name,StartType | ConvertTo-Html -Fragment).Replace('<table>', '<table id="myTable">')
$template.Replace("`$table", $table) | Out-File .\Services.html

Filter table with multiple columns

Just trying to filter a table but also have it filter the number with and without dashes (working) but also search the name and id as well. Its only searching the one column since the index is [0].
How would I have it search all 3 columns? So if I search number or id or name it would filter. Here is the working code I have so far to search number.
<!DOCTYPE html>
<html>
<head>
<style>
* {
box-sizing: border-box;
}
#myInput {
background-image: url('/css/searchicon.png');
background-position: 10px 10px;
background-repeat: no-repeat;
width: 100%;
font-size: 16px;
padding: 12px 20px 12px 40px;
border: 1px solid #ddd;
margin-bottom: 12px;
}
#myTable {
border-collapse: collapse;
width: 100%;
border: 1px solid #ddd;
font-size: 18px;
}
#myTable th, #myTable td {
text-align: left;
padding: 12px;
}
#myTable tr {
border-bottom: 1px solid #ddd;
}
#myTable tr.header, #myTable tr:hover {
background-color: #f1f1f1;
}
</style>
</head>
<body>
<h2>Number search</h2>
<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for names.." title="Type in a name">
<table id="myTable">
<tr class="header">
<th style="width:60%;">Number</th>
<th style="width:60%;">Name</th>
<th style="width:60%;">ID</th>
</tr>
<tr>
<td>905-373-3333</td>
<td>Mike</td>
<td>4563</td>
</tr>
<tr>
<td>905-333-3333</td>
<td>adam</td>
<td>8963</td>
</tr>
<tr>
<td>416-373-3432</td>
<td>Jim</td>
<td>9363</td>
</tr>
</table>
<script>
function myFunction() {
var input, filter, table, tr, td, i, cleanedFilter;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
cleanedFilter = filter.replace("-","");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
if (td) {
cellContent = td.innerHTML.toUpperCase().replace(/-/g,"");
if (cellContent.indexOf(cleanedFilter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>
</body>
</html>
If you want to use a filter for every td available in your rows, you can use the following:
(function(document) {
'use strict';
var LightTableFilter = (function(Arr) {
var _input;
function _onInputEvent(e) {
_input = e.target;
var tables = document.getElementsByClassName(_input.getAttribute('data-table'));
Arr.forEach.call(tables, function(table) {
Arr.forEach.call(table.tBodies, function(tbody) {
Arr.forEach.call(tbody.rows, _filter);
});
});
}
function _filter(row) {
var text = row.textContent.toLowerCase(), val = _input.value.toLowerCase();
row.style.display = text.indexOf(val) === -1 ? 'none' : 'table-row';
}
return {
init: function() {
var inputs = document.getElementsByClassName('light-table-filter');
Arr.forEach.call(inputs, function(input) {
input.oninput = _onInputEvent;
});
}
};
})(Array.prototype);
document.addEventListener('readystatechange', function() {
if (document.readyState === 'complete') {
LightTableFilter.init();
}
});
})(document);
<section class="container">
<input type="search" class="light-table-filter" data-table="order-table" placeholder="Filter">
<table class="order-table table">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Number 2</th>
<th>Number 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Column One</td>
<td>Two</td>
<td>352353</td>
<td>1</td>
</tr>
<tr>
<td>Column Two</td>
<td>Two</td>
<td>4646</td>
<td>2</td>
</tr>
</tbody>
</table>
</section>

HTML2PDF row table cannot page-break

I used HTML2PDF version 4.03 for export data to PDF, my problem is when the data format on table rows (tr) always not break to next-page and if content more than height page the content out of tr table.
I have tried this page break trick, but still does not work, please give me solutions.
Screenshots of the problem:
Here is my CSS:
body {width:100%;height:auto; }
hr {border-width:0.3px; border-color:#000; margin:8px 0;}
h1, h2, h3 {margin:0 0 0 0;}
h1 {text-transform: uppercase;}
h2 {font-size:20px;text-transform: uppercase;}
h3 {font-size:16px;}
div {font-size:15px;height:auto;}
p {margin:7px 0;}
.mb0 {margin-bottom:0px!important;}
.mb20 {margin-bottom:20px!important;}
.mt0 {margin-top:0px!important;}
.centered {
text-align:center;
}
.header {
text-align: center;
}
.header h1 {font-size:25px;}
.w40 {
float:left;
width:38%;
margin-left:2%;
margin:10px 0;
display:inline;
position:relative;
}
.w60 {
float:left;
width:58%;
margin-right:2%;
margin:10px 0;
display:inline;
position:relative;
}
.w100 {
float:left;
width:100%;
display:inline;
position:relative;
}
.logo {
width:75%;
padding:2px;
}
table td {
padding:3px 0;
}
.clearfix {
clear:both;
margin:0;
}
.sk h3{
margin-bottom:5px;
text-transform: uppercase;
}
label {
margin:0px 0 50px;
font-size:14px;
text-align: right;
font-weight: bold;
}
.tgl-sah {
position:absolute;left:77px;top:-5px;font-size:13px;color:#143754;font-weight:bold;
}
.w530 {
width:530px;
text-align: justify;
}
.sub-h3 {margin:7px 0;}
And here is HTML
<table class="tb-partai" cellspacing="0">
<tr>
<th>No.</th>
<th style="border-left:none;width:250px">partai Politik</th>
<th style="border-left:none;width:170px;">Struktur<br/>Kepengurusan</th>
<th style="border-left:none;width:170px">Kantor Pusat</th>
<th style="border-left:none;width:235px">Riwayat Permohonan</th>
</tr>
<?php
$no = 0;
foreach($partai->result_array() as $p) {
$no = $no + 1;
if($no % 2 == 1) {
echo "<tr style='background:#FFF'>";
} else {
echo "<tr style='background:#EFF1FF'>";
}
$sk_last = $this->db->select('*');
$sk_last = $this->db->order_by('id','desc');
$sk_last = $this->db->limit(1);
$sk_last = $this->db->get_where('rz_riwayat_parpol', array('id_parpol'=>$p['id']));
foreach($sk_last->result_array() as $sk) { ?>
<td class="t-center"><?php echo $no; ?>.</td>
<td style="border-left:none;width:265px">
<table>
<tr>
<td style="width:125px;"><img src="<?php echo base_url().'uploads/'.$sk['logo']; ?>"></td>
<td style="padding-left:5px;">
<?php echo "<h2>".$sk['nama_parpol']."</h2>";
echo "<p style='margin:3px 0'>".$sk['alias_parpol']."</p>";?>
<p style="margin:3px 0">Didirikan : <?php echo dateIndo(GetValue('rz_parpol',$sk['id_parpol'],'tgl_didirikan'));?></p>
<?php if($sk['status'] == "Berbadan Hukum") { ?>
<div style="width:165px;position:relative">
<img src="<?php echo base_url().'assets/images/bg-badanhukum.png'; ?>">
<span class="bdn-hukum" style="margin-left:45px"><?php echo dateIndo($sk['tgl_disahkan']);?></span>
</div>
<?php } ?>
</td>
</tr>
</table>
</td>
<td style="border-left:none;max-width:170px">
<table>
<tr>
<td>Ketua Umum</td><td> : </td><td><?php echo $sk['ketum']; ?></td></tr>
<tr>
<td>Sek. Jenderal</td><td> : </td><td><?php echo $sk['sekjend']; ?></td></tr>
<tr>
<td>Bend. Umum</td><td> : </td><td><?php echo $sk['bendum']; ?></td></tr>
<tr>
<td>Ketua MA</td><td> : </td><td style="width:90px;"><?php echo $sk['ketua_ma']; ?></td></tr>
<tr>
<td>Anggota MA</td><td> : </td><td></td></tr>
<tr>
<td colspan="3" style="width:185px"><table><?php echo anggota_ma($sk['anggota_ma'])."</table>"; ?></td></tr>
</table>
</td>
<td style="border-left:none;width:170px"><?php echo $sk['kantor_pusat']; ?></td>
<?php } ?>
<td style="border-left:none;width:350px;text-align:justify">
<?php $sk_partai = $this->db->get_where('rz_riwayat_parpol', array('id_parpol'=>$p['id']));
$nomor = 0;
foreach($sk_partai->result_array() as $skp) {
$nomor = $nomor + 1;
echo "<table>
<tr><td style='width:15px;padding-bottom:8px;'>".$nomor.".</td><td style='width:335px;padding-bottom:8px;line-height:20px'>
<b>".getValue('rz_srt_masuk', $skp['id_srt_permohonan'], 'no_kendali')."</b> - <span style='color:#323B7E;'>".dateIndo(getValue('rz_srt_masuk', $skp['id_srt_permohonan'], 'tgl_srt'))."</span> <br/>".getValue('rz_srt_masuk', $skp['id_srt_permohonan'], 'perihal')."</td></tr></table>";
} ?>
</td>
</tr>
<?php } ?>
</table>
Thanks

my css result in ipad 2 doesn't work well

I have my result in Windows PC like this:
pic, and everything is fine.
My piece of css code is like this:
.colkiri{
display: table-cell;
border-left: 1px solid #FEBA0E; /*orange*/
min-width: 20px;
}
But, if i open it in my IPAD 2, it looks like this: pic. It's like the border-left none, not solid anymore, whereas i don't change anything in my code. Why?
My fully css (admintree.css):
#boxpost{
height: auto;
border-bottom: 1px dotted #FEBA0E; /*orange*/
}
#commentleftside{
margin-left:10
}
#bigbox{
width: auto;
display: table;
}
.nomorver{
color: #369; /*biru gelap*/
font-size: 80%;
font-weight: bold;
font-family: verdana; /*nempel tulisannya*/
word-spacing: 15px;
display: table-cell;
vertical-align:middle;
width: 40px;
}
.colkiri{
display: table-cell;
border-left: 1px none #FEBA0E; /*orange*/
min-width: 20px;
}
.colkanan{
display: table-cell;
}
.colkananchild{
border-left: 1px solid #FEBA0E; /*orange*/
float: left;
}
#username{
white-space:nowrap;
padding-top: 0px;
}
#username:before{
content:" \00a0\00a0\00a0\00a0\00a";
text-decoration:line-through;
color: #FEBA0E;
}
.usernamechild{
color: #369; /*biru gelap*/
font-size: 80%;
font-weight: bold;
font-family: verdana; /*nempel tulisannya*/
word-spacing: 15px;
}
.usernamechild a {
color: #369; /*biru gelap*/
text-decoration: none;
}
.usernamechild a:hover {
color: #369; /*biru gelap*/
text-decoration: underline;
mouse: pointer;
}
.note{
color: #888;
font-size: x-small;
font: normal x-small verdana,arial,helvetica,sans-serif;
}
.joinunder{
color: #FFFF00;
font-size: x-small;
font: normal x-small verdana,arial,helvetica,sans-serif;
background-color: red;
padding-left: 5px;
padding-right: 5px;
border-radius: 25px;
}
.joinunder a {
color: #FFFF00; /*biru gelap*/
text-decoration: none;
}
.joinunder a:hover {
color: #FFFF00; /*biru gelap*/
text-decoration: underline;
mouse: pointer;
}
and my fully HTML:
<?php
include('sbmcon.php');
include('logincheckadmin.php');
?>
<html>
<head>
<title>Admin Tree</title>
<link rel="shortcut icon" href="/img/sbmico.ico">
<link rel='stylesheet' type='text/css' href='/css/admintree.css'>
<style>
.umpetin{
margin-left:50px;
}
</style>
<style>
.borderred{
border:2px solid red;
padding-left: 2px;
padding-right: 2px;
}
.bordergreen{
border:2px solid green;
padding-left: 2px;
padding-right: 2px;
}
</style>
<script type="text/javascript">
function pujoinunder(pageURL, title, w, h) {
var left = (screen.width - w) / 2;
var top = (screen.height - h) / 2; // for 25% - devide by 4 | for 33% - devide by 3
var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
}
function pudelrec(pageURL, title, w, h) {
var left = (screen.width - w) / 2;
var top = (screen.height - h) / 2; // for 25% - devide by 4 | for 33% - devide by 3
var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
}
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-resource.min.js"></script>
</head>
<body ng-app="ctrljs">
<?php
$page=isset($_REQUEST['page'])?$_REQUEST['page']:null;
$ssloginadmin=$_SESSION['ssloginadmin'];
$qitungitung=mysql_query("SELECT a.cv AS CountVer, a.mv AS MaxVer, a.cv-a.mv AS selisih FROM
(SELECT COUNT(ver) AS cv, MAX(ver) AS mv FROM t_un WHERE upgrade='1') a");
$fitungitung=mysql_fetch_object($qitungitung);
if($fitungitung->selisih<>0){
$msgitungitung="<span class='borderred'><font color='red'><strong>pohon rusak (please press fixver and fixtcount)</font></span>";
}else{
$msgitungitung="<span class='bordergreen'><font color='green'><strong>pohon bagus</strong></font></span>";
}
echo "
<a href='?page=fixver' style='text-decoration: none' ><input type='button' value='fix ver'></input></a>
<a href='?page=fixtcount' style='text-decoration: none' ><input type='button' value='fix tcount'></input></a>
<button type='button' onclick=\"javascript:putreeadd('treeadd.php?start=yes','test',400,250)\">add</button>
<button type='button' onclick=\"javascript:pudelrec('admintreedelrec.php?page=form','test',400,250)\"><font color='red'>Delete Multiple Record</font></button>
<a href='treefilter.php?start=yes' style='text-decoration: none' target='_blank'><input type='button' value='filter'></input></a>
<br>
CountVer=$fitungitung->CountVer, MaxVer=$fitungitung->MaxVer, Selisih=$fitungitung->selisih, berarti=$msgitungitung
";
//executed
$q=mysql_query("SELECT ai,ver,hor,t,username,namealias,city,sponsor,upline,sponsorcount,sponsorcounttree,t1name,t2name,t1count,t2count,email,mlmid,hp,bb,ve,status,upgrade FROM t_un WHERE upgrade='1' ORDER BY ver,t");
while($f=mysql_fetch_object($q)){
echo "
<div id='bigbox'><span class='nomorver' nowrap>$f->ver.</span>
";
for($a=1;$a<=$f->hor-1;$a++){
echo "
<div class='colkiri'></div>
";
}
echo "
<div class='colkanan'>
<div class='colkananchild'>
<div id='username'>
<span class='usernamechild'>$f->username</span>
";
if($f->t1count==0 || $f->t2count==0){
echo "<span class='joinunder'>join under</span> ";
}
if($f->t1count==0 && $f->t2count==0){
echo "<span class='joinunder'>x</span> ";
}
echo "
<span class='note'>hor=$f->hor, t=$f->t, email=$f->email, ".($f->mlmid=="none"?"<span class='joinunder'>IDC2G=$f->mlmid</span>":"IDC2G=$f->mlmid").", <font color='red'>sponsor=</font>$f->sponsor, <font color='blue'>upline=</font>$f->upline, t1name=$f->t1name, t2name=$f->t2name, <font color='red'>sponsorcount=</font>$f->sponsorcount, <font color='red'>sponsorcounttree=</font>$f->sponsorcounttree, t1count=$f->t1count, t2count=$f->t2count, <font color='red'>ve=</font>$f->ve, <font color='red'>upgrade=</font>$f->upgrade
<!--
<div class='umpetin' id='formjoin$f->ver' style='display:none;'>
<iframe style='border: 1px solid #FEBA0E; padding: 5px' src='admintreeupgrade.php?page=form&un=$f->username' width='400px' height='205px'></iframe>
</div>
-->
</div>
</div>
</div>
</div>
";
}
echo "
</div>
";
if($page=='fixver'){
fixver();
}
if($page=='fixtcount'){
fixtcount();
}
if($page=='delrec'){
$un=isset($_REQUEST['un'])?$_REQUEST['un']:null;
mysql_query("DELETE FROM t_un WHERE username='$un'");
fixver();
fixtcount();
echo "<script type='text/javascript'>window.location='admintree.php'</script>";
}
$submit=isset($_REQUEST['submit'])?$_REQUEST['submit']:null;
if($submit=='yes'){
$cl=isset($_REQUEST['cl'])?$_REQUEST['cl']:null;
$arrayid = implode(', ',$cl);
mysql_query("UPDATE t_un SET mw='1' WHERE ai IN(".$arrayid.")");
echo "<script type='text/javascript'>window.location='admintree.php'</script>";
}
$signout=isset($_REQUEST['signout'])?$_REQUEST['signout']:null;
if($signout=='yes'){
unset($_SESSION['ssloginadmin']);
unset($ssloginadmin);
echo "<script type='text/javascript'>window.location = 'http://sbm.website'</script>";
}
function fixver(){
//blocking, jika sedang ada proses
$q6=mysql_query("SELECT status FROM t_process");
$f6=mysql_fetch_object($q6);
if($f6->status=='yes'){
echo "
<center>
<div class='alert alert-danger'>
<h3><span class='glyphicon glyphicon-remove'></span> Wait....</h3>
Someone is processing , try again in a few second, thank you.
</div>
<button type='button' onclick=\"history.back();\" class='btn btn-danger'>back</button>
</center>
";
exit;
}
//start
mysql_query("UPDATE t_process SET status='yes'");
$n=0;
$q2=mysql_query("SELECT ver,username FROM t_un WHERE upgrade='1' ORDER BY ver");
while($f2=mysql_fetch_object($q2)){
$count++;
mysql_query("UPDATE t_un SET ver='$count' WHERE username='$f2->username'");
}
//finish
mysql_query("UPDATE t_process SET status='no'");
echo "<script language=javascript> alert('Fix Ver done')</script>";
echo "<script type='text/javascript'>window.location='admintree.php'</script>";
//echo "fixver ready";
}
function fixtcount(){
mysql_query("UPDATE t_process SET status='1'");
mysql_query("UPDATE t_un SET t1count='0',t2count='0',t1name=null,t2name=null");
$q2=mysql_query("SELECT username FROM t_un WHERE upgrade='1' ORDER BY ver DESC");
while($f2=mysql_fetch_object($q2)){
$simpanupline=$f2->username;
do {
//penghitungan upline nomor 2 dan seterusnya keatas
$simpanupline2=$simpanupline;
$q=mysql_query("SELECT upline,t FROM t_un WHERE username='$simpanupline2'");
$f=mysql_fetch_object($q);
$simpanupline=trim($f->upline);
$simpanT=$f->t;
mysql_query("UPDATE t_un SET t$simpanT".'count'."=t$simpanT".'count'."+1, t$simpanT".'name'."='$simpanupline2' WHERE username='$simpanupline'");
} while($simpanupline2<>'sbm');
}
mysql_query("UPDATE t_process SET status='0'");
echo "<script language=javascript> alert('Fix Tcount done')</script>";
echo "<script type='text/javascript'>window.location='admintree.php'</script>";
//echo "fixtcount ready";
}
?>
<script>
$('.joinunder').click(function(){
var divToToggle = $($(this).find('a').attr('href'));
divToToggle.slideToggle('slow');
$('.umpetin:visible').not(divToToggle).hide('slow');
});
</script>
</body>
</html>

Split Table After X Number of Rows & Add Text in While Loop (Using TCPDF)

I have this statement which produces as many rows as it should do:
$result = mysqli_query($con,"SELECT * FROM b_sale_basket WHERE ORDER_ID=$ID ORDER BY PRICE * QUANTITY DESC");
$total=0;
while($row = mysqli_fetch_array($result))
{
$quantity = $row['QUANTITY'];
$description = $row['NAME'];
$unitprice = $row['PRICE'];
$lineprice = $row['PRICE']*$row['QUANTITY'];
$total=$total+$lineprice;
$tbl_header = '<table style="width: 650px;" cellspacing="0" cellpadding="5">';
$tbl_footer = '</table>';
$tbl = '';
$tbl .= '
<tr>
<td style="width: 50px; text-align: left; border-bottom: 0.1em solid #808080;"><p style="color:#808080;">'.number_format($quantity,0).'</p></td>
<td style="width: 350px; border-bottom: 0.1em solid #808080;"><p style="color:#808080;">'.$description.'</p></td>
<td style="width: 125px; text-align:right; border-bottom: 0.1em solid #808080;"><p style="color:#808080;">'.number_format($unitprice,2).'</p></td>
<td style="width: 125px; text-align:right; border-bottom: 0.1em solid #808080;" align="right" ><p style="color:#808080;">'.number_format($lineprice,2).'</p></td>
</tr>
';
$pdf->writeHTML($tbl_header . $tbl . $tbl_footer, true, false, false, false, '');
As mentioned this returns the correct data. However, I have a footer on the page set with SETXY within TCPDF and the table goes over this. What I need is to add the text:
$pdf->AddPage();
After 10 rows and then the table continues on the next page.
Any ideas? If this can't be done, is there anyway of setting the setxy to not just sit in the background of the page?
You just need a simple looping counter:
$tbl = '';
$counter = 0;
// foreach item in your array...
$counter++;
if ($counter > 9) {
$pdf->AddPage();
$counter = 0;
}
$tbl .= '
Edit: you probably want to refactor the way you're looping but as you have it written now the solution is:
$result = mysqli_query($con,"SELECT * FROM b_sale_basket WHERE ORDER_ID=$ID ORDER BY PRICE * QUANTITY DESC");
$total=0;
$counter = 0; //implement a counter
while($row = mysqli_fetch_array($result))
{
$counter++; //increment the counter on each loop
$quantity = $row['QUANTITY'];
$description = $row['NAME'];
$unitprice = $row['PRICE'];
$lineprice = $row['PRICE']*$row['QUANTITY'];
$total=$total+$lineprice;
$tbl_header = '<table style="width: 650px;" cellspacing="0" cellpadding="5">';
$tbl_footer = '</table>';
$tbl = '';
$tbl .= '
<tr>
<td style="width: 50px; text-align: left; border-bottom: 0.1em solid #808080;"><p style="color:#808080;">'.number_format($quantity,0).'</p></td>
<td style="width: 350px; border-bottom: 0.1em solid #808080;"><p style="color:#808080;">'.$description.'</p></td>
<td style="width: 125px; text-align:right; border-bottom: 0.1em solid #808080;"><p style="color:#808080;">'.number_format($unitprice,2).'</p></td>
<td style="width: 125px; text-align:right; border-bottom: 0.1em solid #808080;" align="right" ><p style="color:#808080;">'.number_format($lineprice,2).'</p></td>
</tr>
';
if ($counter > 9) {
$pdf->AddPage();
$counter = 0;
}
$pdf->writeHTML($tbl_header . $tbl . $tbl_footer, true, false, false, false, '');