-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_csv_file.php
More file actions
executable file
·55 lines (55 loc) · 1.6 KB
/
read_csv_file.php
File metadata and controls
executable file
·55 lines (55 loc) · 1.6 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<html>
<head>
<style>
table {
width:500px;
border: #CCCCCC 1px solid;
background-color: #555555;
color:#FFFFFF;
font-family: "Century Gothic",CenturyGothic,AppleGothic,sans-serif;
}
td {
padding: 5px;
}
tr.data {
background-color: #FAFFFF;
color:#000000;
}
div {
color:#FAFAFA;
font-size:12px;
width:60px;
letter-spacing:1px;
padding:2px;
text-align: center
}
</style>
</head>
<body>
<?php
$CSVfp = fopen("fruits.csv", "r");
if ($CSVfp !== FALSE) {
?>
<table cellspacing="1">
<tr>
<td align="center">NAME</td>
<td align="center">COLOR</td>
</tr>
<?php
while (!feof($CSVfp)) {
$data = fgetcsv($CSVfp, 1000, ",");
?>
<tr class="data">
<td align="center"><?php echo $data[0]; ?></td>
<td align="center"><div style="background-color:<?php echo $data[2]; ?>"><?php echo $data[1]; ?></div></td>
</tr>
<?php
}
?>
</table>
<?php
}
fclose($CSVfp);
?>
</body>
</html>