Solved

Help with dynamic page layout.

Posted on 2001-06-06
12
134 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
 

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now