PHP Source Code: fread.php
<?php
//----------------------------------------------------------
// The Web Language Project
// Mark Brautigam
// May-June 2015
// http://www.mixed-up.com/markb/
//----------------------------------------------------------
include "common.php";
headers1();
headers2();
echo sidebar("php", "fread", "php");
?>
<div id="content">
<h2>PHP: Display File Data Contents</h2>
<table class='results'>
<tr><th>College</th><th>Dept.</th><th>Course</th><th>Description</th><th>Edit</th></tr>
<?php
//-------------------------------------------------------------
// The main PHP code is here.
//-------------------------------------------------------------
$courses = file ("../data/courses.txt");
$ncourses = count ($courses);
for ($i=0; $i<$ncourses; $i++) {
$coursedata = explode ("|", trim($courses[$i]));
echo "<tr><td>{$coursedata[0]}</td><td>{$coursedata[1]}</td>" .
"<td>{$coursedata[2]}</td><td>{$coursedata[3]}</td>\n";
echo "<td><a href='fedit.php?id=$i'><img src='../images/pencil.svg' /></a></td>\n";
echo "</tr>\n";
}
//-------------------------------------------------------------
?>
</table>
<p><a href='fwrite.php'>Write to this file »</a></p>
<p><a href='source.php?f=2'>Show PHP source code »</a>
</div>
<?php
footers();
?>