-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsv_data_reader.php
More file actions
74 lines (61 loc) · 1.81 KB
/
Copy pathcsv_data_reader.php
File metadata and controls
74 lines (61 loc) · 1.81 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
</style>
<title>Retrive dropdown data in csv</title>
</head>
<body>
<h2>Retrive data directly from CSV to your web page!</h2>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
<select name="sl" id='slct'><option >THIS IS DROP DOWN MENU</option>
<?php
$f=fopen("dropdown.csv","r") or die("ERROR! unable to open ");
$column=0;
while(!feof($f))
{
$row=fgetcsv($f)[$column];
// foreach($row as $col)
// {
echo "<option value='$row'>$row</option>";
// }
}
fclose($f);
?>
</select>
<?php
$f=fopen("dropdown.csv","r") or die("ERROR!");
//echo "something";
if(isset($_POST['sub']))
{
echo "<table border=1 cellspacing=0 >";
while(!feof($f))
{
$row=fgetcsv($f);
$x=$row[0];
if($_POST['sl']===$x)
{
echo "<tr>";
echo "<td>$row[0]</td>";
echo "<td>$row[1]</td>";
echo "<td>$row[2]</td>";
echo "<td>$row[3]</td>";
echo "</tr>";
}
else
{
echo "";
}
}
echo "</table>";
}
fclose($f);
?>
<br><br>
<input type="submit" value="SHOW DATA" name="sub">
</form>
</body>
</html>