[code=php]<?php
$rootpath=’C:Userstest’;
$fileinfos=new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($rootpath)
);
foreach($fileinfos as $pathname)
{
if (!$pathname->isfile()) continue;
if ( strrpos($pathname,’_’) == true)
{
$file = ‘C:Userspathname.txt’;
$f = @fopen($file, “r+”);
if ($f !== false) {
ftruncate($f, 0);
fclose($f);
}
$current = file_get_contents($file);
// Append a new person to the file
$current .= $pathname;
echo “file name is:”.$current;
// Write the contents back to the file
file_put_contents($file, $current);
//print ‘Copy not exists’.$pathname.'<br/>’; open
$file1=explode(“\”,$pathname);
$file2=explode(“.”,$file1[5]);
$tname=”CV_”.$file2[0];
echo “the table name is : “. $tname;
FillCVdatabase($pathname, $tname);
$plotfile = ‘C:xampphtdocscv.txt’;
$f1 = @fopen($plotfile, “r+”);
if ($f1 !== false) {
ftruncate($f1, 0);
fclose($f1);
}
$currentplotfile=file_get_contents($plotfile);
$plotfiledata=file_get_contents($pathname);
// Append a new person to the file
$currentplotfile .= $plotfiledata;
// Write the contents back to the file
file_put_contents($plotfile, $plotfiledata);
//echo “tablename:”.$tname; open
$filenameforhtmltable=$pathname;
//$plotdir=mkdir(“C:xampphtdocsplotsdirectory”, 0700);
$output = shell_exec(“root -l -q cv_root.C”);
echo “<pre>”.var_export($output, true).”</pre>”;
}
}
Function FillCVdatabase($filename, $tablename)
{
$db = new mysqli(“localhost”,””,””,”test”);
$handle = fopen($filename, ‘r’);
//————————————————-first row
$data = fgets($handle);
$fields = explode(“t” , $data);
//—————————————————————————second row
$data = fgets($handle);
$values = explode(“t” , $data);
$vc = count($values);
$vi=0;
$val=””;
while($vi < ($vc-1))
{
$val .= “‘”.$values[$vi].”‘,”;
$vi++;
}
$val .= “‘”.$values[$vi].”‘”;
//————————— database insert
//print “insert into exp_info values ($val);”;
$db->query( “insert into cv_info values (NULL,$val);”);
//———————————-3rd row
$data = fgets($handle);
$row = explode(“t” , $data);
$fc = count($row);
$fi=0;
$fname=””;
$fv=””;
while($fi < ($fc – 1))
{
//print $fi.”:”.$row[$fi]. “(“. strlen($row[$fi]).”)” .”t”;
$fname.= “f”.($fi).” varchar(50),”;
$fv.=”‘”.$row[$fi].”‘,”;
$fi++;
}
$fname.= “f”.($fi).” varchar(50)”;
$fv.=”‘”.$row[$fi].”‘”;
print “create table $tablename ($fname);”;
$db->query(“create table $tablename ($fname);”);
$db->query(“insert into $tablename values ($fv);”);
//—————————– 3rd row +
$i=1;
while (false === feof($handle) )
{
$data = fgets($handle);
$row = explode(“t” , $data);
$fc = count($row);
$fi=0;
$fv=””;
while($fi < ($fc – 1))
{
$fv.=”‘”.$row[$fi].”‘,”;
$fi++;
}
$fv.=”‘”.$row[$fi].”‘”;
$db->query(“insert into $tablename values ($fv);”);
$i++;
}
//—————————————
fclose($handle);
$db->close();
}
?>
the table with tablename is not showing at phpmyadmin, what can be the possible cause of this?
kindly avail a solution.