First of all, I'm new to this level of PHP, so my apologies!
My goal is to create an HTML table that lists the title, type, size, and date of a document sorted by the project to which the document belongs. Like this:

I can get the data out of MYSQL with
I can create the table with project as a column with
But I'm stumped as to where to go from here. Basically I want to print the project_name as a <h2> before the table with the relevant documents listed in the table.
I know it must be so simple and basic, but I am completely missing it and have spent hours looking for a solution on the web. What am I missing???
Many thanks for your help--I truly appreciate it!
My goal is to create an HTML table that lists the title, type, size, and date of a document sorted by the project to which the document belongs. Like this:

I can get the data out of MYSQL with
Code:
$q = 'SELECT DISTINCT project_name, document_name, document_type, document_size, date_last_modified FROM documents LEFT JOIN projects ON documents.project_id = projects.project_id ORDER BY project_name ASC, date_last_modified DESC';
Code:
if ($r) // ran OK,
{
echo '<table summary="A listing of the project documents"> // Table header.
<thead>
<tr>
<th>Title</th>
<th>Type</th>
<th>Size (KB)</th>
<th>Date Last Modified</th>
</tr>
</thead>';
// Fetch and print all the records
$bg = '#dodcbc'; //set the bg color darker green
while ($row = mysql_fetch_array($r, MYSQL_ASSOC)) {
$bg = ($bg=='#dodcbc' ? '#eff3e9' : '#dodcbc'); //switch the bg color
echo '<tr bgcolor="' .$bg . '">
<td><a href="http://www.p.com/' . $row['filename'] .'"> ' . $row['document_name'] . ' </a></td>
<td>' . $row['document_type'] . '</td>
<td>' . $row['document_size'] . '</td>
<td>' . $row['date_last_modified'] . '</td>
</tr>';
}
echo '</table>'; // Close the table.
mysql_free_result ($r); // Free up the resources.
I know it must be so simple and basic, but I am completely missing it and have spent hours looking for a solution on the web. What am I missing???
Many thanks for your help--I truly appreciate it!
Comment