<?php
$connection=mysql_connect("localhost","someone","project") or die(mysql_error());
mysql_select_db("cdcat", $connection) or die(mysql_error());
//select all products that belong to the users choice
$getRecords = "select cdid, cddesc, printdate, inuseby, foldernr, folderpage, cdcomments from versions, os, languages, cds, products where prodname='" .$_POST[s1]."' and language='" .$_POST[s2]."' and os='" .$_POST[s3]."'and versionname='" .$_POST[s4]."' and versions.versionid=cds.versionid and languages.languageid=cds.languageid and products.prodid=cds.prodid and os.osid=cds.osid order by cddesc;";
$getRecordsRes = mysql_query($getRecords, $connection) or die(mysql_error());
//check if there are any records that fit the select above
if (mysql_num_rows($getRecordsRes) < 1)
{
//there are no records
$display = "<P><strong>No records match your selection</strong></P>";
} else {
//create the table to display records
$display="
<table cellpadding=3 cellspacing=1 border=1>
<tr>
<th><b>CD ID</b></th>
<th><b>CD Description</b></th>
<th><b>Date of Print</b></th>
<th><b>Currently used by</b></th>
<th><b>Found in folder</b></th>
<th><b>On page</b></th>
<th><b>Comments</b></th>
<th><b>Action</b></th>
</tr>";
//loop through record
while ($recInfo = mysql_fetch_array($getRecordsRes))
{
$cdid = $recInfo['cdid'];
$desc = stripslashes($recInfo['cddesc']);
$date = strftime("%x", strtotime($recInfo['printdate']));
$used = stripslashes($recInfo['inuseby']);
$folder = $recInfo['foldernr'];
$page = $recInfo['folderpage'];
$comments = stripslashes($recInfo['cdcomments']);
if (!($comments)) { $comments = " "; }
if (!($used)) { $used = " "; }
//add to display
$display .="
<tr>
<td>$cdid</td>
<td>$desc</td>
<td>$date</td>
<td><input type=text name=use size=20 value=\"$used\"></td>
<td>$folder</td>
<td>$page</td>
<td><input type=text name=comm value=\"$comments\"></td>
<td align=center><a href=\"updatef.php?cdid=$cdid\">update</a></td>
</tr>";
}
//close the table
$display .="
</table>";
}
?>
<html>
<head><title>List of selected CDs</title></head>
<LINK REL=stylesheet TYPE="text/css" HREF="project.css">
<body>
<IMG ALIGN=left SRC="logo.gif">
<br><br><br><br><br><br><br>
<center>
<h2>List of selected CDs</h2>
<?php echo $display; ?></center>
<br>
<h5><p align=left><a href="updatestep1.php">Go back</a> to the main search page<br><a href="update.php">Return</a> to the main update page</p></h5>
</body>
</html>