I'm using php 5.2, mysql 5.0.22 and a Windows 2000 server.
My database is structured like so:
DB:
clfile ,
clfile_name
clfile_size
clfile_type
clfile_title
description
date_entered
cl_association,
cl_assoc_id
cl_file_id
cl_category_id
approved
categories
cl_category_id
cl_category
What I want to do is have all of the categories list out and each file list underneath them in a bullet list without having to use a form to select the categories. I have my code ready to where it will display one category and the files that are in that category but I'm not sure how to get all of them to do the same.
here is my code:
PHP Code:
<?php //view_files.php
$page_title = 'View Files';
$first = TRUE;
require_once ('../_connect/intranet_connect.php');
$query ="Select cl_category_id FROM cl_categories";
$result = mysql_query($query);
(list ($type) = mysql_fetch_array($result, MYSQL_NUM));
{
$query = "SELECT cl_category FROM cl_categories WHERE cl_category_id=$type";
$result= mysql_query($query);
list ($category) = mysql_fetch_array($result, MYSQL_NUM)OR die(mysql_error());
$first=TRUE;
$query = "SELECT c.clfile_id, clfile_name, clfile_title, DATE_FORMAT(date_submitted, '%M %e, %Y') as d , description FROM clfile AS c, cl_association AS ca WHERE c.clfile_id = ca.clfile_id AND ca.cl_category_id=$type AND ca.approved = 'Y' ORDER BY date_submitted DESC";
$result = mysql_query ($query);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
if($first)
{
echo "<table border=\"0\" width=\"80%\" cellspacing=\"3\" cellpadding=\"3\" align=\"center\">
<tr>
<td><strong>$category</strong></td>
<Td><strong>Date</strong></td>
</tr>";
$first = FALSE;
}
echo "<tr><ul>
<td align=\"left\"><li><a href=\"../php/test/download.php?uid={$row['clfile_id']}\">{$row['clfile_title']}</a></td>
<td><font color=\"red\">*{$row['d']}*</li></td></a>
</tr>\n";
}
if($first)
{
echo'<p>There are no files</p>';
}
else
{
echo '</table>';
}
}
mysql_close();
?>
Sorry about the long post. Thank you all for your help!