<html>
<head>
<meta charset="utf-8">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" type="text/javascript"></script>
<script src="jquery.tablesorter.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("#csv_table").tablesorter();
}
);
</script>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data" name="import">
<label for="input_import_file">Umístění CSV souboru:</label>
<input name="import_csvfile" id="import_csvfile" type="file">
<input name="csvsubmit" id="csvsubmit" type="submit">
</form>
<?php
if($_FILES['import_csvfile']['tmp_name']){
echo '<table id="csv_table" width="100%" border="1" cellspacing="5" cellpadding="0">';
$handle = fopen($_FILES['import_csvfile']['tmp_name'], "r");
while (($data = fgetcsv($handle, 1000, ",")) !==FALSE) {
$num = count($data);
echo "<tr>";
for ($c=0; $c < $num; $c++) {
echo "<td> ".$data[$c]."</td>"."\n";
}
echo "</tr>";
}
fclose($handle);
echo "</table>";
}
?>
</body>
</html>
如何设置和为从 CSV 文件生成的表?
表是使用循环(for 和 while 函数)生成的,我不知道如何设置第一行,或者我是否应该设置表静态。
请帮助我,我是初学者。
提前致谢