I have this code here, where it is allowed to be uploaded and overwrite on database. But I do not know how do I actually allow it to show the CSV detail on my webpage. Anybody can help?
<?php
session_start();
if (isset($_POST["Upload"])) {
include "dbFunctions.php";
mysql_select_db($DB) or die(mysql_error());
$filename = $_FILES["file"]["tmp_name"];
if ($_FILES["file"]["size"] > 0) {
$file = fopen($filename, "r");
$count = 0;
do {
$excelData = fgetcsv($file, 10000, ",");
if ($excelData === FALSE && $count == 0) {
break;
} elseif ($excelData !== FALSE) {
if (count($excelData) < 8) {
break;
}
$count++;
$sql = "INSERT into profile (id, password, name, dob, contact, email, gender, module, school) values ('" . $excelData[0] . "',SHA1('" . $excelData[1] . "'),'" . $excelData[2] . "','" . $excelData[3] . "','" . $excelData[4] . "','" . $excelData[5] . "','" . $excelData[6] . "','" . $excelData[7] . "','" . $excelData[8] . "') ON DUPLICATE KEY UPDATE password=SHA1('" . $excelData[1] . "'), name='$excelData[2]', dob='$excelData[3]', contact='$excelData[4]', email='$excelData[5]', gender='$excelData[6]', module='$excelData[7]', school='$excelData[8]'";
mysql_query($sql);
}
} while ($excelData !== FALSE);
if ($count > 0) {
$msg = 'CSV File has been successfully imported!';
} else {
$msg = 'Invalid File. Please check that the file is uploaded in .CSV format!';
}
// echo $msg;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="stylesheet/style.css" rel="stylesheet"/>
</head>
<body>
<h2>Load Details</h2>
<br>
<?php
echo $msg
?>
<br>
<table align='center' border='3' cellpadding='5' cellspacing='0'>
<tr>
<th>ID </th>
<th>Password</th>
.....
</tr>
</table>
<?php
echo "<tr>";
echo "<td>" "</td>";
echo "</tr>";
?>
</body>
what to put in the table??