...

View Full Version : Problem in table format



newphpcoder
02-17-2012, 01:03 AM
Hi...

Good day!

I just want to know how can I change the format of my table. here is my code:




<?php
include 'config.php';

$sql = "SELECT DATE_FORMAT(d.FROM_DATE, '%M %c') AS FROM_DATE, DATE_FORMAT(d.TO_DATE, '%M %c, %Y') AS TO_DATE, g.EMP_NO, g.fullName, g.Rate, g.Reg_Hours, g.Basic_Pay, g.OTReg_Hours, g.SunReg_Hours, g.OTSun_Hours, g.HolReg_Hours, g.HolRegOT_Hours, g.HolLeave_Hours_Tot, SUM(g.NPReg_Hours + g.NPSun_Hours + g.NPHol_Hours) AS NIGHT_PREMIUM, SUM(g.MealReg_Hours + g.MealSun_Hours) AS MEAL_ALLOWANCE, g.Cola_Hours, g.Basic_Pay, g.OTReg_Amt, g.SunReg_Amt, g.OTSun_Amt, g.HolReg_Amt, g.HolRegOT_Amt, g.HolLeave_Amt, g.NP_Amt, g.Meal_Amt, g.Cola_Amt, p.COMPANY_NAME, p.PERIOD, p.NAME, p.FIRST_LINE, p.RATE_Label, p.EARNINGS, p.HRS, p.AMOUNT, p.BASIC_PAY_Label, p.REGULAR_OVERTIME, p.SUN_SPEC_HOLIDAY, p.SUN_SPEC_HOL_OT, p.REG_HOLIDAY, p.REG_HOLIDAY_OT, p.HOLIDAY_LEAVE, p.NIGHT_PREMIUM_Label, p.MEAL_ALLOWANCE_Label, p.COLA, p.13TH_MONTH, p.SECOND_LINE FROM $PAYROLL.casual_payslip_label p, $PAYROLL.casual_generate_payroll g, $PAYROLL.casual_date_upload d GROUP BY g.EMP_NO"or die(mysql_error());
$rs_label = $conn2->GetAll($sql);

$smarty->assign('rs_label', $rs_label);
$smarty->display('payslip.tpl');
$smarty->display('casual_payslip.tpl');
?>

<div>
{section name=att loop=$rs_label}
<table class="stat">
<tr>
<td>{$rs_label[att].COMPANY_NAME}</td>
<tr/>

<tr>
<td>{$rs_label[att].PERIOD} {$rs_label[att].FROM_DATE}-{$rs_label[att].TO_DATE}</td>
<tr/>

<tr>
<td>{$rs_label[att].NAME} {$rs_label[att].fullName}</td>
</tr>

<tr>
<td>{$rs_label[att].FIRST_LINE}</td>
</tr>

<tr>
<td>{$rs_label[att].RATE_Label} {$rs_label[att].Rate}</td>
</tr>

<tr>
&nbsp;&nbsp;<td>{$rs_label[att].EARNINGS}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].HRS}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].AMOUNT}</td>
</tr>

<tr>
<td>{$rs_label[att].BASIC_PAY_Label}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].Reg_Hours}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].Basic_Pay}</td>
</tr>

<tr>
<td>{$rs_label[att].REGULAR_OVERTIME}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].OTReg_Hours}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].OTReg_Amt}</td>
</tr>

<tr>
<td>{$rs_label[att].SUN_SPEC_HOLIDAY}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].SunReg_Hours}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].SunReg_Amt}</td>
</tr>

<tr>
<td>{$rs_label[att].SUN_SPEC_HOL_OT}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].OTSun_Hours}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].OTSun_Amt}</td>
</tr>

<tr>
<td>{$rs_label[att].REG_HOLIDAY}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].HolReg_Hours}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].HolReg_Amt}</td>
</tr>

<tr>
<td>{$rs_label[att].REG_HOLIDAY_OT}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].HolRegOT_Hours}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].HolRegOT_Amt}</td>
</tr>

<tr>
<td>{$rs_label[att].HOLIDAY_LEAVE}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].HolLeave_Hours_Tot}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].HolLeave_Amt}</td>
</tr>

<tr>
<td>{$rs_label[att].NIGHT_PREMIUM_Label}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].NIGHT_PREMIUM}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].NP_Amt}</td>
</tr>

<tr>
<td>{$rs_label[att].MEAL_ALLOWANCE_Label}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].MEAL_ALLOWANCE}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$rs_label[att].Meal_Amt}</td>
</tr>

<tr>
<td>{$rs_label[att].COLA}{$rs_label[att].Cola_Hours}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {$rs_label[att].Cola_Amt}</td>
</tr>

<tr>
<td>{$rs_label[att].SECOND_LINE}</td>
</tr>
</table>
{/section}
</div>


the output of this code:

Company Name
Period : jul 09- July 22,2011
Name : Juan Dela Cruz

Rate : 339.80
EARNINGS HRS AMOUNT
Basic Pay 91.45 3,884.34
Regular Overtime 0.00 0.00
Sun/Spec Holiday 0.00 0.00
Sun/Spec Hol. OT 0.00 0.00
Reg. Holiday 0.00 0.00
Reg. Holiday OT 0.00 0.00
Holiday/Leave 0.00 0.00
Night Premium 0.00 0.00
Meal Allowance 0.00 0.00
COLA (P28 Allow) 0.00 0.00
13th Month 0.00


Company Name
Period : jul 09- July 22,2011
Name : Ann Chin

Rate : 339.80
EARNINGS HRS AMOUNT
Basic Pay 100.00 4247.5
Regular Overtime 0.00 0.00
Sun/Spec Holiday 0.00 0.00
Sun/Spec Hol. OT 0.00 0.00
Reg. Holiday 0.00 0.00
Reg. Holiday OT 0.00 0.00
Holiday/Leave 0.00 0.00
Night Premium 0.00 0.00
Meal Allowance 0.00 0.00
COLA (P28 Allow) 0.00 0.00
13th Month 0.00


Company Name
Period : jul 09- July 22,2011
Name : John Lee

Rate : 339.80
EARNINGS HRS AMOUNT
Basic Pay 101 4289.96
Regular Overtime 0.00 0.00
Sun/Spec Holiday 0.00 0.00
Sun/Spec Hol. OT 0.00 0.00
Reg. Holiday 0.00 0.00
Reg. Holiday OT 0.00 0.00
Holiday/Leave 0.00 0.00
Night Premium 0.00 0.00
Meal Allowance 0.00 0.00
COLA (P28 Allow) 0.00 0.00
13th Month 0.00


Company Name
Period : jul 09- July 22,2011
Name : Mary Ann Chan

Rate : 339.80
EARNINGS HRS AMOUNT
Basic Pay 90 3,882.75
Regular Overtime 0.00 0.00
Sun/Spec Holiday 0.00 0.00
Sun/Spec Hol. OT 0.00 0.00
Reg. Holiday 0.00 0.00
Reg. Holiday OT 0.00 0.00
Holiday/Leave 0.00 0.00
Night Premium 0.00 0.00
Meal Allowance 0.00 0.00
COLA (P28 Allow) 0.00 0.00
13th Month 0.00

I have a lot of employee so the data is long.

I attach the format I want to happen.

Thank you

Taro
02-17-2012, 02:03 AM
Hello newphpcoder,

You can simply put each company name and section as a table cell. For example, if this was in HTML and CSS only, it would be:




<table>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>4</td><td>5</td><td>6</td></tr>
</table>



Just replace the number with your set of data.:D

newphpcoder
02-17-2012, 02:16 AM
Hello newphpcoder,

You can simply put each company name and section as a table cell. For example, if this was in HTML and CSS only, it would be:




<table>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>4</td><td>5</td><td>6</td></tr>
</table>



Just replace the number with your set of data.:D

this is the format of my code, my problem is how can I put the second employee data not below the first employee data but beside of it. because now it happen is they are all in the left side. the other side is blank so it excess in paper if i print it.

THank you

JustS
02-17-2012, 06:49 AM
<table border="1">
<tr><td> Stuff in here </td> <td> Stuff in here </td> </tr>
<tr> <td> Stuff in here </td> <td> Stuff in here </td> </tr>
</table>

http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_table_test



I hope this helps a little

JustS
02-17-2012, 06:53 AM
<td>{$rs_label[att].COMPANY_NAME}</td>
<tr/>

<tr>
<td>{$rs_label[att].PERIOD} {$rs_label[att].FROM_DATE}-{$rs_label[att].TO_DATE}</td>
<tr/>

What's this?

felgall
02-17-2012, 09:07 PM
You are missing the <thead> and <tbody> tags that allow you to distinguish the heading rows at the top of the table and to break the body of the table up into sections.

Adding those tags would make styling the table easier.

You shouldn't attempt to apply any styling of the data from the HTML - that's what CSS is for.

newphpcoder
02-20-2012, 01:18 AM
Actually i already revised my code to change the design but still it was one side or one line. How can I add the thead and tbody>what is the use of that?Thank you

here is my code:

[code]
<div>
{section name=att loop=$rs_label}
<table class="stat" border = "0" width="auto">
<tr>
<td colspan="6" align="center"><b>{$rs_label[att].COMPANY_NAME}</b></td>
<tr/>

<tr>
<td colspan="3" align="center"><b>{$rs_label[att].fullName}</b></td> <td colspan="3" align="center"><b>{$rs_label[att].Rate}</b></td>
</tr>

<tr>
<td colspan="3"><b>{$rs_label[att].PERIOD} {$rs_label[att].FROM_DATE}-{$rs_label[att].TO_DATE}</b></td> <td colspan="3" align="center"><b>{$rs_label[att].RATE_Label}</b></td>
<tr/>

<tr>
<td colspan="3"><b>{$rs_label[att].EARNINGS}</b></td> <td colspan="3"><b>{$rs_label[att].DEDUCTIONS_Label}</b></td>
</tr>

<tr>
<td colspan="1"></td><td colspan="1" align="right">{$rs_label[att].HRS}</td><td colspan="1" align="right">{$rs_label[att].AMOUNT}</td><td colspan="1"></td><td colspan="1" align="right">{$rs_label[att].HRS}</td><td colspan="1" align="right">{$rs_label[att].AMOUNT}</td>
</tr>

<tr>
<td colspan="1">{$rs_label[att].BASIC_PAY_Label}</td><td colspan="1" align="right">{$rs_label[att].Reg_Hours}</td><td colspan="1" align="right">{$rs_label[att].Basic_Pay}</td><td colspan="1">{$rs_label[att].Late_Label}</td><td colspan="1" align="right">{$rs_label[att].Late_Hours}</td><td colspan="1" align="right">{$rs_label[att].Late}</td>
</tr>

<tr>
<td colspan="1">{$rs_label[att].REGULAR_OVERTIME}</td><td colspan="1" align="right">{$rs_label[att].OTReg_Hours}</td><td colspan="1" align="right">{$rs_label[att].OTReg_Amt}</td><td colspan="1">{$rs_label[att].WITHHOLDING_TAX_Label}</td><td colspan="1" align="right"></td><td colspan="1" align="right">{$rs_label[att].TAX}</td>
</tr>

<tr>
<td colspan="1">{$rs_label[att].SUN_SPEC_HOLIDAY}</td><td colspan="1" align="right">{$rs_label[att].SunReg_Hours}</td><td colspan="1" align="right">{$rs_label[att].SunReg_Amt}</td><td colspan="1">{$rs_label[att].SSS_CONTRIBUTION_Label}</td><td colspan="1" align="right"></td><td colspan="1" align="right">{$rs_label[att].SSS}</td>
</tr>

<tr>
<td colspan="1">{$rs_label[att].SUN_SPEC_HOL_OT}</td><td colspan="1" align="right">{$rs_label[att].OTSun_Hours}</td><td colspan="1" align="right">{$rs_label[att].OTSun_Amt}</td><td colspan="1">{$rs_label[att].MEDICARE_CONT_Label}</td><td colspan="1" align="right"></td><td colspan="1" align="right">{$rs_label[att].PCHL}</td>
</tr>

<tr>
<td colspan="1">{$rs_label[att].REG_HOLIDAY}</td><td colspan="1" align="right">{$rs_label[att].HolReg_Hours}</td><td colspan="1" align="right">{$rs_label[att].HolReg_Amt}</td><td colspan="1">{$rs_label[att].HDMF_Label}</td><td colspan="1" align="right"></td><td colspan="1" align="right">{$rs_label[att].HDMF}</td>
</tr>

<tr>
<td colspan="1">{$rs_label[att].REG_HOLIDAY_OT}</td><td colspan="1" align="right">{$rs_label[att].HolRegOT_Hours}</td><td colspan="1" align="right">{$rs_label[att].HolRegOT_Amt}</td><td colspan="1">{$rs_label[att].SSS_Loan_Label}</td><td colspan="1" align="right"></td><td colspan="1" align="right">{$rs_label[att].SSS_Amor}</td>
</tr>

<tr>
<td colspan="1">{$rs_label[att].HOLIDAY_LEAVE}</td><td colspan="1" align="right">{$rs_label[att].HolLeave_Hours_Tot}</td><td colspan="1" align="right">{$rs_label[att].HolLeave_Amt}</td><td colspan="1">{$rs_label[att].HDMF_Loan_Label}</td><td colspan="1" align="right"></td><td colspan="1" align="right">{$rs_label[att].HDMF_Amor}</td>
</tr>

<tr>
<td colspan="1">{$rs_label[att].NIGHT_PREMIUM_Label}</td><td colspan="1" align="right">{$rs_label[att].NIGHT_PREMIUM}</td><td colspan="1" align="right">{$rs_label[att].NP_Amt}</td><td colspan="1">{$rs_label[att].TAX_ADJT_Label}</td><td colspan="1" align="right"></td><td colspan="1" align="right">{$rs_label[att].TaxAjt}</td>
</tr>

<tr>
<td colspan="1">{$rs_label[att].MEAL_ALLOWANCE_Label}</td><td colspan="1" align="right">{$rs_label[att].MEAL_ALLOWANCE}</td><td colspan="1" align="right">{$rs_label[att].Meal_Amt}</td><td colspan="1">{$rs_label[att].Cash_Advance_Label}</td><td colspan="1" align="right"></td><td colspan="1" align="right">{$rs_label[att].CashAdvance}</td>
</tr>

<tr>
<td colspan="1">{$rs_label[att].COLA}</td><td colspan="1" align="right">{$rs_label[att].Cola_Hours}</td><td colspan="1" align="right">{$rs_label[att].Cola_Amt}</td><td colspan="1">{$rs_label[att].Advances_Shirt_Label}</td><td colspan="1" align="right"></td><td colspan="1" align="right">{$rs_label[att].AdvanceShirt}</td>
</tr>

<tr>
<td colspan="1"></td><td colspan="1" align="right"></td><td colspan="1" align="right"></td><td colspan="1">{$rs_label[att].Advances_Medical_Label}</td><td colspan="1" align="right"></td><td colspan="1" align="right">{$rs_label[att].AdvanceMed}</td>
</tr>

<tr>
<td colspan="1"></td><td colspan="1" align="right"></td><td colspan="1" align="right"></td><td colspan="1">{$rs_label[att].Advances_Others_Label}</td><td colspan="1" align="right"></td><td colspan="1" align="right">{$rs_label[att].AdvanceOther}</td>
</tr>


<tr>
<td colspan="1"></td><td colspan="1" align="right"></td><td colspan="1" align="right"></td><td colspan="1">{$rs_label[att].CANTEEN_Label}</td><td colspan="1" align="right"></td><td colspan="1" align="right">{$rs_label[att].Canteen}</td>
</tr>

<tr>
<td colspan="1"></td><td colspan="1" align="right"></td><td colspan="1" align="right">{$rs_label[att].LINE_Label}</td><td colspan="1"></td><td colspan="1" align="right"></td><td colspan="1" align="right">{$rs_label[att].LINE_Label}</td>
</tr>

<tr>
<td colspan="1"><b>{$rs_label[att].TOTAL_EARNINGS_Label}</b></td><td colspan="1" align="right"></td><td colspan="1" align="right"><b>{$rs_label[att].TotalEarnings}</b></td><td colspan="1"><b>{$rs_label[att].TOTAL_DEDUCTIONS_Label}</b></td><td colspan="1" align="right"></td><td colspan="1" align="right"><b>{$rs_label[att].TotalDeductions}</b></td>
</tr>

<tr>
<td colspan="1"></td><td colspan="1" align="right"></td><td colspan="1" align="right"></td><td colspan="1"></td><td colspan="1" align="right"></td><td colspan="1" align="right"></td>
</tr>

<tr>
<td colspan="3" align="center">{$rs_label[att].Receipt_Pay}</td><td colspan="1"></td><td colspan="1" align="right"></td><td colspan="1" align="right"></td>
</tr>
<tr>
<td colspan="3" align="center">{$rs_label[att].Receipt_Detail}</td><td colspan="1"></td><td colspan="1" align="right"></td><td colspan="1" align="right"></td>
</tr>

<tr>
<td colspan="3" align="center">{$rs_label[att].Receipt_Detail1}</td><td colspan="1"></td><td colspan="1" align="right"></td><td colspan="1" align="right"></td>
</tr>

<tr>
<td colspan="3" align="center">{$rs_label[att].Receipt_Detail2}</td><td colspan="1"></td><td colspan="1" align="right"></td><td colspan="1" align="right"></td>
</tr>

<tr>
<td colspan="1"></td><td colspan="1" align="right"></td><td colspan="1" align="right"></td><td colspan="1"></td><td colspan="1" align="right"></td><td colspan="1" align="right"></td>
</tr>

<tr>
<td colspan="1"></td><td colspan="1" align="right"></td><td colspan="1" align="right"></td><td colspan="1"></td><td colspan="1" align="right"></td><td colspan="1" align="right"></td>
</tr>

<tr>
<td colspan="3" align="center">{$rs_label[att].fullName}</td><td colspan="1"></td><td colspan="1" align="right"></td><td colspan="1" align="right"></td>
</tr>

<tr>
<td colspan="3" align="center">{$rs_label[att].FIRST_LINE}</td><td colspan="1"></td><td colspan="1" align="right"></td><td colspan="1" align="right"></td>
</tr>

<tr>
<td colspan="3" align="center">{$rs_label[att].SIGNATURE}</td><td colspan="1"><b>{$rs_label[att].TAKE_HOME_PAY_Label}</b></td><td colspan="1" align="right"></td><td colspan="1" align="right"><b>{$rs_label[att].TakeHomePay}</b></td>
</tr>

<tr>
<td colspan="1"></td><td colspan="1" align="right"></td><td colspan="1" align="right"></td><td colspan="1"></td><td colspan="1" align="right"></td><td colspan="1" align="right">{$rs_label[att].SECOND_LINE}</td>
</tr>

<tr>
<td colspan="6">{$rs_label[att].FOURTH_LINE}</td>
</tr>

</table>

{/section}
</div>
[code]
I want is like this
Payslip Employee 1 Payslip Employee 2 Payslip Employee 3
List of data1 List of data 2 List of data 3 a

And so onů


Now the result of my code is :

Payslip Employee 1
List of data1

Payslip Employee 2
List of data2

Payslip Employee 3
List of data3

Payslip Employee 4
List of data4

Payslip Employee 5
List of data5

Payslip Employee 6
List of data6

Thank you



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum