The first part of this article discussed the basic design andarchitecture for an intranet document management system. In this concludingpart, get to the good stuff with a discussion of the "check in" and "checkout" process, and add a simple search engine to the system.
You'll remember that the document information page, "details.php", also contains a link to the document's revision history. That history is generated by the script "history.php", which queries the "log" table to build a list of changes made to the document.
The first part of the script simply provides the same document information seen in "details.php" - the description, size and so on. Once that's over with, a query to the "log" and "user" tables builds a list of changes made to the specific file, sorted by date.
<table border="0" cellspacing="5" cellpadding="5">
<tr>
<td><font size="-1"><b>Modified on</b></font>
<td><font size="-1"><b>By</b></font>
<td><font size="-1"><b>Note</b></font> </td>
</tr>
<?
// query to obtain a list of modifications
$query = "SELECT user.username, log.modified_on, log.note FROM log, user
WHERE log.id = '$id' AND user.id = log.modified_by ORDER BY log.modified_on
DESC";
$result = mysql_db_query($database, $query, $connection) or die ("Error in
query: $query. " . mysql_error());
// iterate through resultset
while(list($modified_by, $modified_on, $note) = mysql_fetch_row($result))
{
?>
<tr>
<td><font size="-1"><? echo fixDate($modified_on); ?></font></td>
<td><font size="-1"><? echo $modified_by; ?></font></td>
<td><font size="-1"><? echo $note; ?></font></td>
</tr>
<?
}
// clean up
mysql_free_result($result);
?>
</table>
Here's a sample screen.
This article copyright Melonfire 2001. All rights reserved.