Background Info: I have 2 tables one called cats with categories (ie:Administration) and catid (ie:1,2,3,4..etc.) and another table called links which has catid(ie: 1,2,3,4...etc.), url, title.

Here is what Im trying to do: I already have it displaying everything nice and pretty but now i need to change up how its displayed. I just need the link title under the category. Sounds easy right? Here is what I need it to look like:

Administration
Link
Link
Link

Category2
Link
Link
Link


Problem: Nothing can be hard coded, I can not have a query say where category = administration. The reason nothing can be hard coded is because users can Add/Edit/Remove links and categories without me having to go in and edit code every time someone wants to make changes. I was thinking about using cfloop, find the max catid and counting up to the max catid while looping through the query with the loopnumber.

Some code: Here is some code that lists all the links in a table.

<cfquery name="links" datasource="#application.sb_ds#" username="#application.sb_username#" password="#application.sb_password#">
			SELECT links.name, links.webUrl, cats.category, links.linkid, links.catid, cats.catid
			FROM         zeke_links links, zeke_cats cats
			WHERE     links.catid = cats.catid
			ORDER BY cats.category, name;					
</cfquery> 

<div style="center">
<cfif Form.category EQ "Select a category">

<cflocation url="body.cfm">

<cfelseif Form.category EQ "Full List">

<center><h2>Full List</center></h2>

<TABLE BORDER="2" CELLPADDING="5" CELLSPACING="5">
<tr>
<th align="Center">Name</th>
<th align="center">URL</th>
<th align="center">Category</th>
</tr>
<cfoutput query="links">    
<tr><td>#links.name#</td> 
    <cfif links.webUrl eq "">
     <td>No Website Url Submitted!</td>
        <cfelse>
           <td><a href="#links.webUrl#" target="blank">#links.webUrl#</a></td>
           </cfif>  
           <td>#category#</td>
            </tr>  
  </cfoutput>             
</table>

I am fresh out of ideas, any help would be awesome. Thanks.

I am not giving you all of the code to do exactly what you need, but if you read this code below closely you should be able to get out of your rut with this assignment.

<cfset strLastCatName = "">
<cfoutput query="LINKS">
    <cfif LINKS.Category NEQ strLastCatName>
        <cfset strLastCatName = LINKS.Category>
        #LINKS.Category# <br />
    </cfif>
    <a href="#links.webUrl#" target="blank">#links.webUrl#</a><br />
</cfoutput>

That helps a lot, thanks for pointing me in the right direction hinde.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.