<?php
        session_cache_expire(1440);
        session_start();
        session_name("insys");
        include "include/config.php";
        include "include/functions.php";
        include "class/UctVw.php";
        $ssql="SELECT * from  txpayroll_slip_hdr

                     ";

        $rs=mysql_query($ssql);
        $ssql1=array();
         mysql_query("BEGIN");
        while($r=mysql_fetch_assoc($rs)) {

             $ssql="UPDATE
                                txpayroll_slip_emp a,
                                (SELECT c.fnid,(SELECT IFNULL(COUNT(d.fnid),0)+1
                                                        FROM txpayroll_slip_emp d
                                                        WHERE d.fnid<c.fnid AND
                                                                d.ftpayroll_slip_no='{$r['ftpayroll_slip_no']}'
                                                )
                                        AS m
                                        FROM  txpayroll_slip_emp c
                                        WHERE c.ftpayroll_slip_no='{$r['ftpayroll_slip_no']}'

                                        ) as b

                                SET a.fnindex=b.m
                                WHERE a.ftpayroll_slip_no='{$r['ftpayroll_slip_no']}'  AND
                                         a.fnid=b.fnid";

            $ssql1[]=$ssql;
            mysql_query($ssql);
        }
          mysql_query("COMMIT");
          pr($ssql1);