Hi all,
I have a code which works fine.
<?php
$db = mysql_connect("localhost","root","");
mysql_select_db("test",$db);
$today = date("F j, Y, g:i a");
//echo $today;exit();
$file = "test.txt";
$fp = fopen($file, "r");
$data = fread($fp, filesize($file));
fclose($fp);
$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.
Thanks
Haan