<html>
<head>
<title>Data Request</title>
</head>
<body>
<h1 align="center">Dispatch Report</h1>
<h2 align="center">Wrong Arrives Report</h2>
<table align="center" border="2">
<tr>
<td>Select Shift<br>
<form method="post" action="" name="shiftfrm" id="shiftfrm">
<select name="shiftlist" id="shiftlist">
<option value="" selected="selected">--------</option>
<?php
$dir = opendir ("files");
while (false !== ($file = readdir($dir))) {
if($file!='.' && $file!='..') {
echo '<option value="' . $file . '">' . $file . '</option>';
}
}
?>
</select>
<input type="submit" id="submit" value="Submit"/>
</form>
</td></tr>
<?php
if(!empty($_POST['shiftlist'])) {
$file = 'files/'.$_POST['shiftlist'];
echo $file;
if(file_exists($file)) {
if( ($handle = fopen( $file, 'r' )) !== false )
{
$output = '<table align="center" width="" border="2">';
while( ($data = fgetcsv( $handle )) !== false )
{
$output .= '<tr>';
foreach( $data as $value )
{
$output .= '<td>'.$value.'</td>';
}
$output .= '</tr>';
}
$output .= '</table>';
echo $output;
fclose( $handle );
}
}
}
?>
</table>
</body>
</html>