<?php
session_start();
ob_start();
include("config/database.php");
$conct  = new connectionCreat();
$conct->connectToDB();
$conct->selectDB();
include "config/function.php";
$take_action1   = new actionDo();
$sql_2 			= mysql_query(" SELECT DISTINCT state FROM `tbl_emp_records` WHERE `status`='0'  ")or die(mysql_error()); 
while($rows2	= mysql_fetch_array($sql_2))
{
	$j			= 1;
	$state		= $rows2['state'];
	$sql_4		= mysql_query(" SELECT `state_code` FROM `state` WHERE `state_name`='".$state."' ");	
	$rows4		= mysql_fetch_array($sql_4);
	$state_code	= $rows4['state_code'];
	
	$sql_3 		= mysql_query(" SELECT * FROM `tbl_emp_records` WHERE `status`='0' and `state`='".$state."' order by `emp_name` ASC ")or die(mysql_error()); 
	while($row3	= mysql_fetch_array($sql_3))
	{
		$id		= $row3['id'];
		$sql5	= mysql_query(" UPDATE `tbl_emp_records` SET `emp_code` = '".$state_code."-".$j."' WHERE `id` = '$id' ")or die(mysql_error());		
		$j++;
	}
	echo $rows2['state']." Total Emp:: ".$j;
	echo "<br>";
}
?>