?
Solved

Help with dynamic page layout.

Posted on 2001-06-06
12
Medium Priority
?
180 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

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 400 total points
ID: 6169518
BTW:  You can accept my comment as answer whenever you like.  ;>)

Cheers!  :>)
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

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…
What You Need to Know when Searching for a Webhost Provider
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

771 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