<?php

session_start();
if($_SESSION['dbName']==""){
header("location:../index.php");
}

include("config.inc.php");
//header("Content-Type: text/html; charset=utf8");
$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");
//mysql_query("SET NAMES 'utf8'");
//mysql_query('SET CHARACTER SET utf8');
/*
$query = "select ledger_number, ledger_name from clients";
$res = mysql_query($query);
while($row = mysql_fetch_row($res)){
	$update = "update clients set ledger_name = '$row[1]' where ledger_number='$row[0]';";
	echo $update; echo "<br>";
}*/
$query = "select ledger_number, ledger_name from ledger";
$res = mysql_query($query);
while($row = mysql_fetch_row($res)){
	$update = "update ledger set ledger_name = '$row[1]' where ledger_number='$row[0]';";
	echo $update; echo "<br>";
}

/*
$query = "select item_code, item_description from items";
$res = mysql_query($query);
while($row = mysql_fetch_row($res)){
	$update = "update items set item_description = '$row[1]' where item_code='$row[0]';";
	echo $update; echo "<br>";
}
*/
/*
$query = "select warehouse_code, warehouse_name from warehouse;";
$res = mysql_query($query);
while($row = mysql_fetch_row($res)){
	$update = "update warehouse set warehouse_name = '$row[1]' where warehouse_code='$row[0]';";
	echo $update; echo "<br>";
}*/

/* $query = "select group_code, group_name from grouping;";
$res = mysql_query($query);
while($row = mysql_fetch_row($res)){
	$update = "update grouping set group_name = '$row[1]' where group_code='$row[0]';";
	echo $update; echo "<br>";
} */

/* $query = "select costcent_code, costcent_name from costcent;";
$res = mysql_query($query);
while($row = mysql_fetch_row($res)){
	$update = "update costcent set costcent_name = '$row[1]' where costcent_code='$row[0]';";
	echo $update; echo "<br>";
} */
/* $query = "select ledger_number, ledger_name from suppliers;";
$res = mysql_query($query);
while($row = mysql_fetch_row($res)){
	$update = "update suppliers set ledger_name = '$row[1]' where ledger_number='$row[0]';";
	echo $update; echo "<br>";
} */

/* $query = "select ledger_number, ledger_name from ledger;";
$res = mysql_query($query);
while($row = mysql_fetch_row($res)){
	$update = "update ledger set ledger_name = '$row[1]' where ledger_number='$row[0]';";
	echo $update; echo "<br>";
} */

/* $query = "select transdt_id, TransDt_Description from transdt where TransDt_Description != '';";
$res = mysql_query($query);
while($row = mysql_fetch_row($res)){
	$update = "update transdt set TransDt_Description = '$row[1]' where transdt_id='$row[0]';";
	echo $update; echo "<br>";
}
 */
 /*
$query = "select journaldt_id, journaldt_desc, journaldt_desc1 from journaldt;";
$res = mysql_query($query);
while($row = mysql_fetch_row($res)){
	if($row[1] == '') $row[1] = "NULL";
	else $row[1] = "'".$row[1]."'";
	if($row[2] == '') $row[2] = "NULL";
	else $row[2] = "'".$row[2]."'";
	
	$update = "update journaldt set journaldt_desc = $row[1],journaldt_desc1 = $row[2] where journaldt_id='$row[0]';";
	echo $update; echo "<br>";
}
*/
?>