-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcsv2html.php
38 lines (38 loc) · 1.01 KB
/
csv2html.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
if(!empty(isset($_POST["upload"]))) {
if (($fp = fopen($_FILES["file-input"]["tmp_name"], "r")) !== FALSE) {
?>
<table class="tutorial-table" width="100%" border="1" cellspacing="0">
<?php
$i = 0;
while (($row = fgetcsv($fp)) !== false) {
$class ="";
if($i==0) {
$class = "header";
}
?>
<tr>
<td class="<?php echo $class; ?>"><?php echo $row[0]; ?></td>
<td class="<?php echo $class; ?>"><?php echo $row[1]; ?></td>
<td class="<?php echo $class; ?>"><?php echo $row[2]; ?></td>
</tr>
<?php
$i ++;
}
fclose($fp);
?>
</table>
<?php
$response = array("type" => "success", "message" => "CSV is converted to HTML successfully");
} else {
$response = array("type" => "error", "message" => "Unable to process CSV");
}
}
?>
</div>
<?php if(!empty($response)) { ?>
<div class="response <?php echo $response["type"]; ?>
">
<?php echo $response["message"]; ?>
</div>
<?php } ?>