my task is to read the first row header, and after reading it, it should break..... i am able to read the first row header but im also getting the second complete row too
kindly help me
Code: Select all
<?php
include "connect.php";
if(isset($_POST['submit']))
{
$filename=$_POST['filename'];
// open the text file
$fd = fopen ("$filename", "r");
// initialize a loop to go through each line of the file
while (!feof ($fd))
{
$buffer = fgetcsv($fd, 4096);
// declare an array to hold all of the contents of each
//row, indexed
//echo "n";
// this for loop to traverse thru the data cols
// when this is re-created with MySQL use the mysql_num_fileds() function to get
// this number
for ($i = 0; $i < count($buffer); $i++)
{
if ($buffer[$i] == "")
{
$buffer[$i] = " ";
echo "</br>";
}
// print 's with each index
echo "$buffer[$i]";
}
//echo "n";
}
fclose ($fd);
}
else
{
print "<form action='file.php' method='post'>";
print "Type file name to import:<br>";
print "<input type='text' name='filename' size='20'><br>";
print "<input type='submit' name='submit' value='submit'></form>";
}
?>