Solved

Help with dynamic page layout.

Posted on 2001-06-06
12
172 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Firewall Speed Issue 6 78
ColdFusion Rereplace 3 96
Question to locate the problem 18 147
How to really determine how many  files in hosting 2 22
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…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Suggested Courses

734 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