给定一个html表,其中每个单元格是一个文本输入,只需按一个按钮,就可以将表写入sqlite表。目标是有一个表,用户可以在线更新单元格值,然后将这些更改保存到主机计算机上的sqlite .db文件中。
<!-- THIS IS THE BUTTON -->
<form method="post" action= "file.php">
<!-- THIS IS THE IMPUT TABLE -->
<div class="row"><center>
<?php
$id = "myTable";
$count = 0;
echo "<table id=".$id.">\n\n";
$f = fopen($tableCSV, "r");
while (($line = fgetcsv($f)) !== false) {
echo "<tr>";
foreach ($line as $cell) {
if ($count != 0) {
echo "<td><input value=" . htmlspecialchars($cell) . "></input></td>";
} else {
echo "<td>" . htmlspecialchars($cell) . "</td>";
}
}
echo "</tr>\n";
$count += 1;
}
fclose($f); echo "\n</table>";
}
?>
</center></div>