<?php 
$db_hostname = "localhost";
$db_username = "tapal_raigadsp";
$db_password = "tapal_raigadsp";
$db_database = "tapal_raigadsp";
// Connect to server.
$db_server = mysql_connect($db_hostname, $db_username, $db_password)
    or die("Unable to connect to MySQL: " . mysql_error());
	
// Select the database.
mysql_select_db($db_database)
    or die("Unable to select database: " . mysql_error());

	$i=0;
	$r = mysql_query("SELECT ltr_inword_no,ltr_id FROM incoming_letters_transaction WHERE ltr_inword_no>'17-0001'");
	while($r2=mysql_fetch_array($r))
	{
		$num=$r2['ltr_inword_no'];
		$ltr_id=$r2['ltr_id'];
		list($a,$b) = Explode("-",$num);
		echo "<br>B of ".$i." ".$b;
		if($b>0001 &&$b<0500)
		{ 
	     $i++;
			//echo "<br>B of ".$i." ".$b;
		   // echo "<br>A of ".$i." ".$a;
			
			$num1="17-00".$b;
			echo "<br>num1 of ".$i." ".$num1;
			
			$q=mysql_query("update incoming_letters_transaction set ltr_inword_no='$num1' where ltr_id='$ltr_id'");
		}
		
	}
	
	
?>