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:



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.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;					

<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>

<th align="Center">Name</th>
<th align="center">URL</th>
<th align="center">Category</th>
<cfoutput query="links">    
    <cfif links.webUrl eq "">
     <td>No Website Url Submitted!</td>
           <td><a href="#links.webUrl#" target="blank">#links.webUrl#</a></td>

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

Recommended Answers

All 2 Replies

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 />
    <a href="#links.webUrl#" target="blank">#links.webUrl#</a><br />

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.