Hi all,
I have a code which works fine.

$db = mysql_connect("localhost","root",""); 
$today = date("F j, Y, g:i a");
//echo $today;exit();
$file = "test.txt";
$fp = fopen($file, "r");
$data = fread($fp, filesize($file));
$output = str_replace("\t|\t", "|", $data);
$output = explode("\n", $output);
foreach($output as $var) {
//$categories_id = $categories_id + 1;
$tmp = explode("|", $var);
$name= $tmp[0];
mysql_query("INSERT INTO user_details(name) VALUES('$name',) ") or die(mysql_error()); 
echo "Done!";

This works fine. Now i want to add two fields (runtime_id and date).

Say for Ex: If i insert a file today the runtime_id should be 1 (any number of files can be used to insert into mysql but the runtime_id should be 1 for the same date) and all values should be inserted..
If i insert a file tomorrow the runtime_id should be 2
and the values from my text file should be inserted and so on...
Please help me.


Before inserting into the table, fetch the latest date from the table like;

$res=mysql_query("select max(runtime_id) from user_details")
    $runtime_id=1;//insertion 1 for first time of execution
//now compare date to increase runtime_id 
$res=mysql_query("select max(date_field) from user_details")
    {//$today is what already you are calculating in your code
        // if date is same do nothing,
    else//else increment runtime_id by 1
        $runtime_id=$runtime_id+1;//insertion 1 for first time of execution
/* now use your insertion statement along with these fields
hope this will work
Karthik A*/