Interest Group 1 Description (static HTML content)
#stIG['1'].name# #stIG['1'].email#

Interest Group 2 Description (static HTML content)
#stIG['2'].name# #stIG['2'].email#

[allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => Duane McGuire [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 5 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> combining static & dynamic content - Coldfusion - Getting Started

combining static & dynamic content - Coldfusion - Getting Started

Since the Description is not in the database table, an overall loop over the interest group(IG) records will not work too well, but it would be good to get all the IG records back in one database call. I'd suggest something like the following, which uses query of queries to make it quite efficient: <cfquery name="qIG" datasource="..."> SELECT * from interest_groups </cfquery> Interest Group 1 Description (static HTML content) <cfquery name = "qOne" dbtype="query"> SELECT * from qIG where id=1 </cfquery> <cfoutput>#qOne.name# #qOne.address# ... </cfoutput> Interest Group 2 Description (static HTML content) <cfquery name = "qOne" dbtype="query"> SELECT * from ...

  1. #1

    Default Re: combining static & dynamic content

    Since the Description is not in the database table, an overall loop over the
    interest group(IG) records will not work too well, but it would be good to get
    all the IG records back in one database call. I'd suggest something like the
    following, which uses query of queries to make it quite efficient:

    <cfquery name="qIG" datasource="...">
    SELECT * from interest_groups
    </cfquery>

    Interest Group 1 Description (static HTML content)
    <cfquery name = "qOne" dbtype="query">
    SELECT * from qIG where id=1
    </cfquery>
    <cfoutput>#qOne.name# #qOne.address# ... </cfoutput>


    Interest Group 2 Description (static HTML content)
    <cfquery name = "qOne" dbtype="query">
    SELECT * from qIG where id=2
    </cfquery>
    <cfoutput>#qOne.name# #qOne.address# ... </cfoutput>

    This could be better encapsulized with a function call, but the above gives
    the basic idea.

    Duane McGuire Guest

  2. #2

    Default Re: combining static & dynamic content

    Hi Duane, Thanks for the message - I think your suggestion would be a perfect
    solution, except...we're currently running CF4.0 (yes hard to believe) which
    doesn't support querying of queries. Is there an alternative programatic
    solution in thsi case? I thought about using a one-dimensional array and
    loading each row of data into an element which I could then extract and output
    in a similar manner to the way you've described below. Only trouble is...I
    haven't seen an example of how to extract a row of data and place it into an
    array element. Again, perhaps I'm overthinking and missing an obvious (and
    easier) solution. Any ideas? Again, thank you for your assistance. Gord.

    gbert Guest

  3. #3

    Default Re: combining static & dynamic content

    Sure. If you are not going wild with the number of sections on the page, just
    do a direct query to the database each place I've used query of queries (and
    elimintate the f irst global query).

    Less efficient, but it'll work.

    It's been a loong time since I wrote anything in 4.0, and as I recall, 4.5
    introduced structures. If I had structures available, I'd read the query into
    a struct from the global query, and then present the data from the struct in
    the output. But as I recall, 4.0 did not introduce structs. It's been a few
    years, though, so I could be mistaken. Look for the struct functions in your
    doentation. Minimizing database access is always a good idea.

    Duane McGuire Guest

  4. #4

    Default Re: combining static & dynamic content

    Thanks again Duane. Actually CF4 does have structures - I've been reading
    about them in the CF4 Manual and I too thought this would be a good way to go.
    Unfortunately, I haven't worked with structures before and I've had a heck of a
    time finding examples. Might I impose upon you once more to give a brief
    example of how rows of data from a query can be loaded into a structure (say a
    one dimensional array) and then outputted? Thanks for all your help!! Gord.

    gbert Guest

  5. #5

    Default Re: combining static & dynamic content

    This is how I'd do it:

    <cfquery name="qIG" datasource="...">
    SELECT
    id,
    name,
    email
    from interest_groups
    </cfquery>

    <!--- create a structure to hold the data from the query. --->

    <cfset stIG = structNew()>

    <!---
    Note that inside the loop, each structure element is a structure itself,
    containing all of the row data
    --->

    <cfloop query="qIG">
    <!---
    The following statment creates a the second level structure
    to contain one row of data from the query
    --->

    <cfset dummy = structInsert(stIG, qIG.id, StructNew())>

    <!---
    The next two lines add the data for the row
    --->

    <cfset dummy = structInsert(stIG[id],'name',qIG.name)>
    <cfset dummy = structInsert(stIG[id],'email',qIG.email)>
    </cfloop>

    <!---
    The following assumes that id's 1 and 2 were present in the query result
    --->

    Interest Group 1 Description (static HTML content)<BR>
    <cfoutput>#stIG['1'].name# #stIG['1'].email#</cfoutput><BR><BR>

    Interest Group 2 Description (static HTML content)<BR>
    <cfoutput>#stIG['2'].name# #stIG['2'].email#</cfoutput><BR><BR>

    <!--- Etc. --->

    Duane McGuire Guest

  6. #6

    Default Re: combining static & dynamic content

    Thank you once again for all your help - and the well commented sample!
    It's almost 3:00am here so I'll give it a try tomorrow and let you know how I make out.

    Cheers,
    Gord.

    gbert Guest

  7. #7

    Default Re: combining static & dynamic content

    Hi Duane, Update. I used the code you provided yesterday and it worked great!!
    The code is also a great example from which I can start experimenting with
    structures. Thanks for your patience and assistance. Gord.

    gbert Guest

Similar Threads

  1. Combining Flash & HTML Content
    By Foochuck in forum Macromedia Dynamic HTML
    Replies: 3
    Last Post: December 15th, 03:21 PM
  2. Dynamic to static
    By T McDizzle in forum Coldfusion Database Access
    Replies: 8
    Last Post: July 3rd, 05:50 PM
  3. Replies: 2
    Last Post: July 20th, 12:26 PM
  4. Static vs. Dynamic
    By E-Jax webforumsuser@macromedia.com in forum Macromedia Dynamic HTML
    Replies: 5
    Last Post: November 19th, 03:49 AM
  5. Including Static Content
    By jordan in forum ASP
    Replies: 2
    Last Post: October 14th, 02:52 PM

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
  •