How to specify differing column widths for child columns? - php

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>

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, '');
^^^^^

how to automatically add a second page in mpdf?

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.

DataTable plugin not working with dynamically generated php data?

DataTable plugin not working with dynamically generated php data ?
I am using data table in to display a dynamic table. But its not working.
I tried to use static table its working I don't understand the problem
Here is my HTML Table and js script.
Can anyone solve the issue.
$(document).ready(function () {
$('#myTable').dataTable();
});
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" id="myTable">
<thead>
<tr>
<th width="100" height="30" align="left" bordercolor="#999999" bgcolor="#d3d3d3">Client Name</th>
<th width="100" height="30"align="left" bordercolor="#999999" bgcolor="#d3d3d3">EPIC ID</th>
<th width="100" height="30" align="left" bordercolor="#999999" bgcolor="#d3d3d3">Project Name</th>
<th width="100" height="30"align="left" bordercolor="#999999" bgcolor="#d3d3d3">Category</th>
<th width="100" height="30" align="left" bordercolor="#999999" bgcolor="#d3d3d3">Epic Status</th>
<th width="150" height="30" align="left" bordercolor="#999999" bgcolor="#d3d3d3">Total Estimated Hours</th>
<th width="150" height="30" align="left" bordercolor="#999999" bgcolor="#d3d3d3">Total Time Spent</th>
<th width="150" height="30" align="left" bordercolor="#999999" bgcolor="#d3d3d3" >% Hours Burned</th>
<th width="150" height="30" align="left" bordercolor="#000000" bgcolor="#d3d3d3">% Project Complete</th>
<th width="150" height="30" align="left" bordercolor="#000000" bgcolor="#d3d3d3">Action Status</th>
</tr>
</thead>
<tbody>
<tr <?php if($cnt%2==0){echo "bordercolor='#FFFFFF' bgcolor='#FFFFFF'";}else{echo "bordercolor='#999999' bgcolor='#FFFFFF'";}?>>
<td align="left" width="100" height="30"><?php echo "$ClientName";?></td>
<td align="left" width="100" height="30">
<?php
echo form_open('Riskreport',array('name'=>'s2frm'.$cnt,'target'=>'_blank'));?>
<?php echo "$EPICID";?>
<input type="hidden" name="epickeyid" value="<?php echo "$EPICID";?>" />
<?php echo $formbuild;?>
</form>
</td>
<td align="left" width="100" height="30"><?php echo "$ProjectName";?></td>
<td align="left" width="100" height="30"><?php echo "$Category";?></td>
<td align="left" width="100" height="30"><?php echo "$epic_status";?></td>
<td align="left" width="150" height="30"><?php echo "$TotalEstimatedHours";?></td>
<td align="left" width="150" height="30"><?php echo "$TotalTimeSpentinHours";?></td>
<td align="left" width="150" height="30" <?php if(($variance2>0)&&($variance2<=100)){echo "bgcolor='#92d050'";}else if(($variance2>100)&&($variance2<=120)){echo "bgcolor='#FFC200'";}else if($variance2>120){echo "bgcolor='#ff0000'";}else{echo "bgcolor='#FFFFFF'";}?>><?php echo $variance2prcnt;?></td>
<td align="left" width="150" height="30">
<?php
$PrjtCompleteprcnt=$ops1->getprjctdone($EPICID);
echo $PrjtCompleteprcnt;
?>
</td>
<td align="CENTER" width="150" height="30"><?php echo "$ActionStatus";?></td>
</tr>
</tbody>
</table>

php while loop table repeating fix

I have following do while loop be it keep on repeating the table for each record how to fix it? full table repeat for each record.
Also for every row fetch can I add
<table width="1510" border="1" align="center" cellpadding="2" cellspacing="2" class="table table-bordered" >
<tbody>
<form name="f1">
<? $counter = 1;
$total_marks = 0;
$total_obtain = 0;
while($row_rsDept = mysql_fetch_array($rsDept))
{
if($counter === 1)
{
?>
<tr>
<th width="71" rowspan="3" align="center" valign="middle" scope="col"><h4>Sr. No</h4></th>
<th width="229" align="right" valign="top" scope="col"> </th>
<th colspan="8" align="center" valign="middle" scope="col"><h3>Detail of Marks</h3></th>
</tr>
<tr>
<th rowspan="2" align="left" scope="row"><h4>Subject</h4></th>
<td colspan="2" align="center"><h4>Thoery</h4></td>
<td colspan="2" align="center"><h4>Practical</h4></td>
<td width="134" rowspan="2" align="center" valign="middle"><h4>Marks Obtain</h4></td>
<td width="144" rowspan="2" align="center" valign="middle"><h4>Max Marks</h4></td>
<td width="137" rowspan="2" align="center" valign="middle"><h4>Remarks</h4></td>
<td width="137" rowspan="2" align="center" valign="middle"><h4>Grace Marks</h4></td>
</tr>
<tr>
<td width="134">Obtained Marks</td>
<td width="144">Total Marks</td>
<td width="143">Obtained Marks</td>
<td width="153">Total Marks</td>
</tr>
<? } ?>
<tr>
<th align="left" scope="row"> </th>
<th align="left" scope="row"><?php echo $row_rsDept['SUBJECTS']; ?></th>
<td><?php echo $row_rsDept['THEORYOBTAINEDMARKS']; ?></td>
<td><?php echo $row_rsDept['THEORYTOTALMARKS']; ?></td>
<td><?php echo $row_rsDept['PRACTICALOBATINEDMARKS']; ?></td>
<td><?php echo $row_rsDept['PRACTICALTOTALMARKS']; ?></td>
<td align="center" valign="middle"><?php echo $row_rsDept['MARKSOBTAINED']; ?></td>
<td align="center" valign="middle"><?php echo $row_rsDept['MAXMARKS']; ?></td>
<td align="center" valign="middle"><span class="style8"><?php echo $row_rsDept['REMARKS']; ?></span></td>
<td align="center" valign="middle"><?php echo $row_rsDept['GRACEMARKS']; ?></td>
</tr>
<tr>
<th colspan="6" align="right" valign="middle" scope="row"><h4>Total</h4></th>
<td align="center" valign="middle"><span class="style8"><?php echo $row_rsDept['TOTALMARKS']; ?></span></td>
<td align="center" valign="middle">=total of above ( )</td>
<td align="center" valign="middle"> </td>
<td align="center" valign="middle"> </td>
</tr>
<?php
} ?>
<tr>
<th colspan="10" align="left" valign="middle" scope="row"> </th>
</tr>
<tr>
<th colspan="8" align="left" valign="middle" scope="row"> </th>
<th align="left" valign="middle" scope="row"> </th>
<th align="left" valign="middle" scope="row"> </th>
</tr>
<tr>
<th colspan="8" align="left" valign="middle" scope="row"><br></th>
<th align="left" valign="middle" scope="row"> </th>
<th align="left" valign="middle" scope="row"> </th>
</tr>
</form>
</table>
I tried to fix but not working for me
Inside loop you need to increment counter variable
Inside loop add this line
$counter++;

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