SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Banging my head against a brick wall!

    Hey all, hoping someone can help me here..

    I'm writing a piece of asp to select all information from a database and display it. Sounds simple enough, however i'm running into a small problem.

    The table is arranged like this:
    Category | Topic | Content

    The category could be repeated multiple times, i.e. "Getting Started"
    The topic is the title of the article, and the content.. well, it's the content.

    I'd like to display the Category only when it changes. So if there were 5 records with "Getting Started" as the category, I would like to display this cat once. When it changes to "Advanced", display that once etc etc.

    This is the code I have at the moment: Note(I have taken the topic stuff out at the moment)

    Code ASP:
    <%	
    while not rec.eof
     
    	If  LastCat = rec("Cat") Then
    		html = vbCrLf&rec("Con")
    		Response.Write(html)	
     
    %>
    		<h2><%=LastCat%></h2>
    <%
    	else
    		LastCat = rec("Cat")
    		html = "<h2>"&LastCat&"</h2>"&vbCrLf&rec("Con")
    		Response.Write(html)	
     
    	end if
    	rec.movenext
    Wend	
     
    %>

    Looking at it, the logic seems right, but i could be delusional

    Thanks in advance,

    Dave

  2. #2
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never mind. Sorted it.

    Ended up having to use a cast in the SQL query from nvarchar to Varchar.

    Dave


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •