1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Problem in table format

Discussion in 'Web Design, HTML And CSS' started by newphpcoder, Feb 17, 2012.

  1. newphpcoder

    newphpcoder New Member

    Joined:
    Sep 24, 2010
    Messages:
    101
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Web Programmer
    Location:
    Philippines
    Hi...
    Good day!
    I just want to know how can I change the format of my table. here is my code:
    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>
                          <td>{$rs_label[att].EARNINGS}              {$rs_label[att].HRS}     {$rs_label[att].AMOUNT}</td>
                    </tr>
                    <tr>
                        <td>{$rs_label[att].BASIC_PAY_Label}                {$rs_label[att].Reg_Hours}       {$rs_label[att].Basic_Pay}</td>
                    </tr>
                    <tr>
                        <td>{$rs_label[att].REGULAR_OVERTIME}     {$rs_label[att].OTReg_Hours}       {$rs_label[att].OTReg_Amt}</td>
                    </tr>
                    <tr>
                        <td>{$rs_label[att].SUN_SPEC_HOLIDAY}     {$rs_label[att].SunReg_Hours}       {$rs_label[att].SunReg_Amt}</td>
                    </tr>
                    <tr>
                        <td>{$rs_label[att].SUN_SPEC_HOL_OT}     {$rs_label[att].OTSun_Hours}       {$rs_label[att].OTSun_Amt}</td>
                    </tr>
                    <tr>
                        <td>{$rs_label[att].REG_HOLIDAY}            {$rs_label[att].HolReg_Hours}       {$rs_label[att].HolReg_Amt}</td>
                    </tr>
                    <tr>
                        <td>{$rs_label[att].REG_HOLIDAY_OT}     {$rs_label[att].HolRegOT_Hours}       {$rs_label[att].HolRegOT_Amt}</td>
                    </tr>
                    <tr>
                        <td>{$rs_label[att].HOLIDAY_LEAVE}        {$rs_label[att].HolLeave_Hours_Tot}       {$rs_label[att].HolLeave_Amt}</td>
                    </tr>
                    <tr>
                        <td>{$rs_label[att].NIGHT_PREMIUM_Label}       {$rs_label[att].NIGHT_PREMIUM}       {$rs_label[att].NP_Amt}</td>
                    </tr>
                    <tr>
                        <td>{$rs_label[att].MEAL_ALLOWANCE_Label}     {$rs_label[att].MEAL_ALLOWANCE}       {$rs_label[att].Meal_Amt}</td>
                    </tr>
                    <tr>
                        <td>{$rs_label[att].COLA}{$rs_label[att].Cola_Hours}       {$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
     

Share This Page