Solved

Help with dynamic page layout.

Posted on 2001-06-06
12
154 Views
Last Modified: 2013-12-24
I don't even know if this is possible.

I am trying to have the results of my search dynamicaly populate a table that displays my results.

the table should grow in width and height not to execeed 2 colums but to add as many rows as needed..

EX:

if my search retrieves 1 result then the table would have only 1 colum and 1 row but it 2 results are returned then the table should have 2 colums 1 row if 3 are returned then then have 2colums 2rows(cells with info) on the second row have one cell with infor and the other blank.

is this even possible?????
0
Comment
Question by:jriver12
  • 8
  • 4
12 Comments
 
LVL 3

Expert Comment

by:TEFKASG
ID: 6161553
Yes, it is possible.  :>)


<cfquery datasource="whatever it is" name="SearchResults">
Your query here
</cfquery>

<cfset toggle = 1>

<table>

 <cfoutput query="searchResults">

  <cfif toggle eq 1>  
    <tr> <td>Output search variable here </td>
    <cfset toggle = 2>
  <cfelseif toggle eq 2>
    <td>Output search variable here </td> </tr>
    <cfset toggle = 1?
  </cfif>

 </cfoutput>

  <cfif Toggle = 2>
   <td></td></tr>
  </cfif>

</table>
0
 
LVL 3

Expert Comment

by:TEFKASG
ID: 6161563
This is basically the bare bones way of doing it.  I assume you'll probably want column headings - just insert the row with the column heading before outputting the query.  If you need any addition explaination, just let me know and I'll give you a full description.  :>)

Cheers!
0
 
LVL 3

Expert Comment

by:TEFKASG
ID: 6161577
"<cfset toggle = 1?" is a typo. It should be <cfset toggle = 1>

:>)
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:jriver12
ID: 6163513
TEFKASG,
I have tested the code that you gave(below)+ the code that I had existing and I received the following errors(look at the bottom of the page for error.  can you please clarify.
thanks.


<cfloop list="#form.results#" index="i_result" delimiters=",">

<CFQUERY NAME="searchit2" DATASOURCE="ProductCodes">
SELECT      dbo.Exhibitr.COMPANYNAME, dbo.Exhibitr.CompanyMailingAddress, dbo.Exhibitr.CompanyCity,



dbo.Exhibitr.CompanyState, dbo.Exhibitr.ZIP1, dbo.Exhibitr.CompanyPhone, dbo.Exhibitr.CompanyFax, dbo.Exhibitr.CompanyEmail,



dbo.PRODUCTS.DESCRIPTION
FROM         dbo.Exhibitr, dbo.EXHPROD_, dbo.PRODUCTS
WHERE       dbo.Exhibitr.ExhNum = dbo.EXHPROD_.ExhNUM AND
dbo.PRODUCTS.PRODNum = dbo.EXHPROD_.ProdNUM AND
(dbo.PRODUCTS.DESCRIPTION LIKE '#i_result#')
</CFQUERY>


<cfset toggle = 1>

<table>

<cfoutput query="searchit2">

 <cfif toggle eq 1>  
   <tr> <td>
   <!--- Output search variable here --->
Company: #COMPANYNAME# <br>
Address:#CompanyMailingAddress#<br>
CITY:  #CompanyCity# <BR>
STATE: #CompanyState#<BR>ZIP: #ZIP1#<br>
PHONE:#CompanyPhone#<br>
FAX:#CompanyFax#<br>
EMAIL: <a href=mailto:"#CompanyEmail#"> #CompanyEmail#</a></td>
   <cfset toggle = 2>
 <cfelseif toggle eq 2>
   <td>
   <!--- Output search variable here  --->
   Company: #COMPANYNAME# <br>
Address:#CompanyMailingAddress#<br>
CITY:  #CompanyCity# <BR>
STATE: #CompanyState#<BR>ZIP: #ZIP1#<br>
PHONE:#CompanyPhone#<br>
FAX:#CompanyFax#<br>
EMAIL: <a href=mailto:"#CompanyEmail#"> #CompanyEmail#</a></td> </tr>
   <cfset toggle = 1>
 </cfif>

</cfoutput>

 <cfif Toggle = 2>
  <td></td></tr>
 </cfif>

</table>
</cfloop>

Error code follows:

Error Diagnostic Information
Error in expression:

Toggle = 2

Invalid conditional expression. Perhaps you are using = instead of EQ or IS to compare values.

The error occurred while processing an element with a general identifier of (CFIF), occupying document position (97:2) to (97:18).

0
 
LVL 3

Expert Comment

by:TEFKASG
ID: 6164774
Opps, sorry about that! :>)

 <cfif Toggle = 2>
 <td></td></tr>
 </cfif>

Should be:

<cfif Toggle eq 2>
 <td></td></tr>
</cfif>
0
 

Author Comment

by:jriver12
ID: 6165045
and now for an additional 25 points.

how do I pull the individual values of #i_result#.?

i have tried all I could figure and guess. but when I do get to show them they repeat for as many records as it pulled?

AAAARRHH!!!
0
 
LVL 3

Expert Comment

by:TEFKASG
ID: 6165152

  Could you clarify what exactly are you trying to do?  Where do you want to put the #i_result# value?

  You should be able to get it to display once, by placing the code for outputing the #i_result# value above the line:

<cfoutput query="searchit2">

 This should cause it to display once per iteration through your outer loop.
0
 

Author Comment

by:jriver12
ID: 6165185
Sorry I was  kind of rambling.

However,

When the query is run and there are multiple search topics selected, the query runs and returns values based on the #I_Results#, the problem is that for each topic that the to pics is ran and records were found produces a new table for that topic, and repeats the header information for each table. is there a way to have all the results displayed in one table with the the results of the query displayed in the header just once ie... Products: item1, item2, item3:

here is what I have so far:

<cfloop list="#form.results#" index="i_result" delimiters=",">

 <CFQUERY NAME="searchit2" DATASOURCE="ProductCodes">
SELECT      dbo.Exhibitr.COMPANYNAME, dbo.Exhibitr.CompanyMailingAddress, dbo.Exhibitr.CompanyCity,



dbo.Exhibitr.CompanyState, dbo.Exhibitr.ZIP1, dbo.Exhibitr.tollfreenum, dbo.Exhibitr.CompanyPhone, dbo.Exhibitr.CompanyFax, dbo.Exhibitr.CompanyEmail,



dbo.PRODUCTS.DESCRIPTION
FROM         dbo.Exhibitr, dbo.EXHPROD_, dbo.PRODUCTS
WHERE       dbo.Exhibitr.ExhNum = dbo.EXHPROD_.ExhNUM AND
dbo.PRODUCTS.PRODNum = dbo.EXHPROD_.ProdNUM AND
(dbo.PRODUCTS.DESCRIPTION LIKE '#i_result#')
</CFQUERY>


<cfset toggle = 1>
  <body background="images/marb18.jpg" text="#000000" link="#0033FF" vlink="#FFFF66" alink="#0066FF">
 
  <table cellspacing="10" border="1" align="center" name="Show the results" width="621">

   
    <cfoutput query="searchit2">
      <cfif toggle eq 1>
      <tr>
        <td height="156" colspan="3"> <font face="Geneva, Arial, Helvetica, san-serif" size="3">
          <!--- Output search variable here --->
          <b>#COMPANYNAME#</b> <br>
          #CompanyMailingAddress#<br>
          #CompanyCity# <BR>
          #CompanyState#<BR>
          #ZIP1#<br>
          #tollfreeNUM#<bR>
          Phone:#CompanyPhone#<br>
          Fax:#CompanyFax#<br>
          <a href=mailto:"#CompanyEmail#"> #CompanyEmail#</a></font></td>
        <cfset toggle = 2>
        <cfelseif toggle eq 2>
        <td width="297" valign="top"> <font face="Geneva, Arial, Helvetica, san-serif" size="3">
          <!--- Output search variable here  --->
          <b>#COMPANYNAME#</b> <br>
          #CompanyMailingAddress#<br>
          #CompanyCity# <BR>
          #CompanyState#<BR>
          #ZIP1#<br>
          #tollfreeNUM#<bR>
          Phone:#CompanyPhone#<br>
          Fax:#CompanyFax#<br>
          <a href=mailto:"#CompanyEmail#"> #CompanyEmail#</a></font></td>
      </tr>
      <cfset toggle = 1>
      </cfif>
    </cfoutput>
    <cfif Toggle eq 2>
    <tr>
      <td height="2" colspan="3"></td>
      <td width="297"></td>
      <td width="11"></td>
    </tr>
    </cfif>
  </table>
  <br>
 
  <cfloop>
0
 
LVL 3

Expert Comment

by:TEFKASG
ID: 6165439
Okay.  :>)  You'll need to reorganize your code a little.  It should be as follows:

 
<body>

<table cellspacing="10" border="1" align="center" name="Show the results" width="621">

<*************** YOUR HEADER CODE HERE ************>

<cfloop list="#form.results#" index="i_result" delimiters=",">

<CFQUERY NAME="searchit2" DATASOURCE="ProductCodes">
SELECT      dbo.Exhibitr.COMPANYNAME, dbo.Exhibitr.CompanyMailingAddress, dbo.Exhibitr.CompanyCity,


dbo.Exhibitr.CompanyState, dbo.Exhibitr.ZIP1, dbo.Exhibitr.tollfreenum, dbo.Exhibitr.CompanyPhone, dbo.Exhibitr.CompanyFax,
dbo.Exhibitr.CompanyEmail,

dbo.PRODUCTS.DESCRIPTION
FROM         dbo.Exhibitr, dbo.EXHPROD_, dbo.PRODUCTS
WHERE       dbo.Exhibitr.ExhNum = dbo.EXHPROD_.ExhNUM AND
dbo.PRODUCTS.PRODNum = dbo.EXHPROD_.ProdNUM AND
(dbo.PRODUCTS.DESCRIPTION LIKE '#i_result#')
</CFQUERY>


<cfset toggle = 1>

<cfoutput query="searchit2">
     <cfif toggle eq 1>
     <tr>
       <td height="156" colspan="3"> <font face="Geneva, Arial, Helvetica, san-serif" size="3">
         <!--- Output search variable here --->
         <b>#COMPANYNAME#</b> <br>
         #CompanyMailingAddress#<br>
         #CompanyCity# <BR>
         #CompanyState#<BR>
         #ZIP1#<br>
         #tollfreeNUM#<bR>
         Phone:#CompanyPhone#<br>
         Fax:#CompanyFax#<br>
         <a href=mailto:"#CompanyEmail#"> #CompanyEmail#</a></font></td>
       <cfset toggle = 2>
       <cfelseif toggle eq 2>
       <td width="297" valign="top"> <font face="Geneva, Arial, Helvetica, san-serif" size="3">
         <!--- Output search variable here  --->
         <b>#COMPANYNAME#</b> <br>
         #CompanyMailingAddress#<br>
         #CompanyCity# <BR>
         #CompanyState#<BR>
         #ZIP1#<br>
         #tollfreeNUM#<bR>
         Phone:#CompanyPhone#<br>
         Fax:#CompanyFax#<br>
         <a href=mailto:"#CompanyEmail#"> #CompanyEmail#</a></font></td>
     </tr>
     <cfset toggle = 1>
     </cfif>
   </cfoutput>
   <cfif Toggle eq 2>
   <tr>
     <td height="2" colspan="3"></td>
     <td width="297"></td>
     <td width="11"></td>
   </tr>
   </cfif>
 
 <br>
 
 <cfloop>

</table>

  This should put all of your results in a single table with a single header at the top.  
0
 

Author Comment

by:jriver12
ID: 6169334
thanks it worked great, and I appreciate your time and assistance.
0
 
LVL 3

Expert Comment

by:TEFKASG
ID: 6169356
Glad I could be of help.  :>)

Cheers!
0
 
LVL 3

Accepted Solution

by:
TEFKASG earned 100 total points
ID: 6169518
BTW:  You can accept my comment as answer whenever you like.  ;>)

Cheers!  :>)
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How can I install php on a ngxin server on droplet 5 134
IIS Site Configuration Copy 2 75
Web Site Hosting 10 86
Redirect to HTTPS results in Infinite LOOP 4 111
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…
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

785 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