I have a simple uploading page that will allow a user to upload CSV file into the server.
After the uploading, the page will display the CSV file into an html table format
Code to Display CSV File to HTML:
<?php
echo "<table class='tbl1'>
";
echo "<tr>";
echo "<th>GOUP NO</th>";
echo "<th>PID CODE</th>";
echo "<th>ID CODE</th>";
echo "<th>DESCRIPTION</th>";
echo "</tr>";
$f = fopen("upload\micro_center.csv", "r");
while (($line = fgetcsv($f)) !== false) {
echo "<tr>";
foreach ($line as $cell) {
echo "<td>" . htmlspecialchars($cell) . "</td>";
}
echo "</tr>
";
}
fclose($f);
echo "
</table>";
?>
I want to add a query on how to insert the data in the CSV file or displayed html table into MSSQL database.
Note: Table headers and Database Table Columns are with the same name
CSV File:
0,G068,CNDLDS,Candelaria District
0,CNDLDS,CNDLDSA,Babancal ES
0,CNDLDS,CNDLDSB,Binabalian ES
0,CNDLDS,CNDLDSC,Candelaria Central
0,CNDLDS,CNDLDSD,Catol ES
Thank You for your answers