i would do it like this:
<?php
$con=mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('master',$con);
//(1) Read the text file into a variable
$file = file("ATND.txt");
foreach($file as $line){
//(2) Then we can get rid of the tabs in there:
$line = str_replace("\t"," ", $line);
$fields = explode(" ", $line);
$ecardno = $fields[0];
$cluster = $fields[1];
$atdate = substr($fields[1],0,6);
$attime = substr($fields[1],6,4);
$IO = substr($fields[1],10,1);
$serialno = substr($fields[1],11,5);
$cardrd = substr($fields[1],16);
// get ecode
$ecode = implode('',mysql_fetch_row(mysq_query("SELECT ecode FROM emp_company WHERE ecardno = '$ecardno'")));
$sql = "INSERT INTO at0310 (ecardno, atdate, attime, ...) VALUES ('$ecardno', '$atdate', '$attime', ...)";
mysql_query($sql);
}
echo "Done!";
?>
notice that you'll have to fill the blanks... i didn't wrote all the fields on the insert statement!
hope that helps!