Solved

Problem in cfoutput as CSS like

Posted on 2004-10-26
333 Views
Last Modified: 2013-12-24
hi guys....hope u dont mind helping me again.

first table..css1.tbl

columns (4)
-----------------------------------------------------------------------
id(primary) | elements | opencurlybracket | closedcurlybracket
-----------------------------------------------------------------------
100 | a | { | }
101 | b | { | }
102 | td | { | }
103 | input | { | }
103 | .class | { | }

in my 2nd table..css2.tbl

columns()
id(foreign) | tag | colon | properties | semicolon
---------------------------------------------------------------
100 | color | : | blue | ;
100 | font-style | : | normal | ;
100 | font-size | : | 12px | ;
100 | font-family | arial | ;
101 | color | : | blue | ;
101 | font-style | : | normal | ;
101 | font-size | : | 12px | ;
101 | font-family | arial | ;
102 | color | : | blue | ;
102 | font-style | : | normal | ;
102 | font-size | : | 12px | ;
102 | font-family | arial | ;

of course 101 stands for a, 101 for b, 102 for td......and the rest

my query..

<cfquery name="table2">
select * from css2
</cfquery>

// i outputed table2 and at the same time i query table1

<cfoutput query="table2">
   <cfquery name="table1">
   select * from css1
  where id = '#table2.id#'
   </cfquery>

#table1.elements##table2.opencurlybracket# #table2.tag# #table2.colon# #table2.properties# #table2.semicolon##table2.closedcurlybracket#

</cfoutput>

it gives me this output

a {color:blue;}
a {font-style:normal; }
a {font-size:12px;}
a {font-family:arial;}
b {color:blue;}
b {font-style:normal; }
b {font-size:12px;}
b {font-family:arial;}
td {color:blue;}
td {font-style:normal; }
td {font-size:12px;}
td {font-family:arial;}

well how can i output something like this, CSS..

a {color:blue;
font-style:normal;
font-size:12px;
font-family:arial;}

b{color:blue;
font-style:normal;
font-size:12px;
font-family:arial;}

td {color:blue;
font-style:normal;
font-size:12px;
font-family:arial;}

if i got this output then i can save it as css file(sample.css)

i guess u can solve this pls......... i got no problem editing and inserting all properties in tables..only outputing.
0
Question by:fourth_noel
    2 Comments
     
    LVL 14

    Accepted Solution

    by:
    Hello fourth_noel!

    You can have your code like this :

    <cfquery name="GetCSS1" datasource="#AppDataBase#">
    SELECT * FROM css1
    </cfquery>

    <cfloop query="GetCSS1">
      <cfset css1ID = id>
      <cfquery name="GetCSS2" datasource="#AppDataBase#">
        SELECT * FROM css2
        WHERE id = #css1ID#
      </cfquery>
      <cfoutput>
        #elements##opencurlybracket#
        <cfloop query="GetCSS2">
          #tag##colon##properties##semicolon#
          <cfif currentrow neq recordcount>
            <br>
          </cfif>
        </cfloop>
        #closedcurlybracket#<br><br>
      </cfoutput>
    </cfloop>

    Hope this helps.  Just try it...


    Goodluck!
    eNTRANCE2002 :-)
    0
     

    Author Comment

    by:fourth_noel
    wow...that was great.....hehe... it was working exactly as i wanted....thank u very much eNTRANCE2002......!!!

    c u again............!!
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
    Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
    Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

    856 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now