thisisafakeaccount12
Technical User
I have a page that categorizes information from a MySQL query
The ultimate result I'm trying to acheive is having a major category followed by a subcategory followed by the MySQL results, like this:
Environment (Major Category)
Agriculture (Sub category)
Results from query
Public Works (Major Category)
Transportation (sub Category)
Results from query
etc...
So far I have been able to acheive the sub categories based on the "category" column changing values like this
The major categories have been more of a problem because they appear spuradically. I was thinking something like echoing the major header when category = specified category, but am not sure how to go about it.
Any ideas would be greatly appreciated
The ultimate result I'm trying to acheive is having a major category followed by a subcategory followed by the MySQL results, like this:
Environment (Major Category)
Agriculture (Sub category)
Results from query
Public Works (Major Category)
Transportation (sub Category)
Results from query
etc...
So far I have been able to acheive the sub categories based on the "category" column changing values like this
Code:
$query = 'SELECT * FROM `opportunities` ORDER BY `category` ASC, `dateadded` DESC;';
$TempCategory="";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)) {
$program = $row['program'];
$description = $row['description'];
$funder = $row['funder'];
$duedate = $row['duedate'];
$nofa = $row['nofa'];
$guide = $row['guide'];
$application = $row['application'];
$category = $row['category'];
$categoryname = $row['categoryname'];
//Changes category on cat change
if($category!=$TempCategory) {
echo '<tr>
<td colspan="4">$category</td>
<tr>';
$TempCategory = $category;
}
//echo's sql results in a table
echo "
<tr>
<td>$program</td>
<td>$description</td>
<td>$funder</td>
<td>$duedate</td>
<td>$nofa$guide$application</td>
</tr>\n";
}
Any ideas would be greatly appreciated