Problem in cfoutput as CSS like

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.
fourth_noelAsked:
Who is Participating?
 
Renante EnteraConnect With a Mentor Senior PHP DeveloperCommented:
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
 
fourth_noelAuthor Commented:
wow...that was great.....hehe... it was working exactly as i wanted....thank u very much eNTRANCE2002......!!!

c u again............!!
0
All Courses

From novice to tech pro — start learning today.