Thanks to all of you, it work! JJ
----- Original Message ----- From: "Ferguson, Ken" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, April 19, 2002 11:33 AM Subject: RE: Query in 2 columns? > Good point Ricardo. Also, in my sleep-deprived state I sent a piece of code > with a small error in it. I looked at it this morning and it jumped right > out at me. Where the closing table tag is, there should also be a closing > tag for the last row. Here is the corrected code for my solution. Sorry > about that. > > <cfif consulta.recordcount> > <table width="594" border="1" cellspacing="0" cellpadding="0"> > <cfset row = 1> > <cfoutput query="consulta" group="fname"> > <cfset temp = row mod 2> > <cfif row mod 2> > <tr> > </cfif> > <td><b>#fName#</b><br> > <cfoutput>#bugDesc#, </cfoutput> > </td> > <cfset row = row +1> > <cfif row mod 2> > </tr> > </cfif> > </cfoutput> > </tr> > </table> > </cfif> > > -----Original Message----- > From: Ricardo Sanoja [mailto:[EMAIL PROTECTED]] > Sent: Friday, April 19, 2002 9:49 AM > To: [EMAIL PROTECTED] > Subject: RE: Query in 2 columns? > > Personally I still use the same method as Seth, but I always set a > variable to determine the number of columns needed, instead of Mod(). > Just Like JLucido posted when this issue first came up. The reason I do > this is simple "today they may want 2 columns, tomorrow they may want > 3". > > Sincerely, > Ricardo Sanoja > Senior Web Architect > Version 4 Technologies, LLC. > 4288 Kellway Circle > Addison, TX 75001-4200 > > 972.267.1558 Ext 19 > [EMAIL PROTECTED] > > > > -----Original Message----- > From: Seth Bienek [mailto:[EMAIL PROTECTED]] > Sent: Friday, April 19, 2002 1:03 AM > To: [EMAIL PROTECTED] > Subject: RE: Query in 2 columns? > > > Hi Javier, > > You're *almost* there. A quick look at the HTML generated by the output > of > your template should give you a good idea of what's the matter. I > commented > your code below to illustrate the problem, but running the page and then > viewing the source will really explain this better than I can. > > <!-- Open a table. ---> > <table width="594" border="1" cellspacing="0" cellpadding="0"> > > <!-- Loop through the grouped rows returned by the query --> > <cfoutput query="consulta" group="cat_name"> > > <!-- If the row number is odd, start a new HTML table row. This is your > main problem. If you want two columns, you should close the HTML table > row > and start a new one AFTER an EVEN record is displayed (see the fixed > code > below). --> > <cfif consulta.currentrow mod 2> > <tr> > <!--- This is the other part of the problem. For every odd numbered > record > returned by the query, you open a new row tag and stuff in a table cell, > never closing the previous row. I don't care what anybody says, table > rows > and cells MUST be closed, AND properly nested. The older HTML spec may > allow these tags to remain open, but it does not work in practice. > XHTML1 > (the current W3C spec) requires that every tag be closed, and that all > attributes be quoted. Again, this problem is addressed in the fixed > code > below. --> > </cfif> > <td><b>#cat_name#</b><br> > <cfoutput>#subcat_name#, </cfoutput> > </td> > </cfoutput> > <!-- note that in your HTML output, there is only one closing row tag > for > all of the rows that were open above.. tsk, tsk! ;) --> > </tr> > </table> > > > Here is the fixed code. I hope it makes sense. If not, shout and I'll > try > to explain it better. Like I said, opening the page you're having > problems > with in a browser and selecting 'View Source' is really the best > explanation > of what's wrong. > > <!-- Open the table and first row explicitly. --> > <table width="594" border="1" cellspacing="0" cellpadding="0"> > <tr> > > <!-- Now every cell and row are opened and closed in the loop. --> > <cfoutput query="consulta" group="cat_name"> > <td><b>#cat_name#</b><br> > <cfoutput>#subcat_name#, </cfoutput> > </td> > <!-- If this is an even row returned from the query, close the HTML row > and > open a new one. --> > <cfif consulta.currentrow mod 2 is 0> > </tr> > <tr> > </cfif> > > </cfoutput> > > <!-- If the query returned an odd number of rows, fill in the last table > cell. (not necessary, but good coding practice, and it will make your > page > look nicer.) --> > <cfif consulta.recordcount mod 2> > <td> </td> > </cfif> > > <!-- Now explicitly close the last table row, and the table itself. --> > </tr> > </table> > > See? Simple. All you have to do is think like a web browser. :) > > Take Care, > > Seth > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On > Behalf Of > Javier Flores > Sent: Thursday, April 18, 2002 7:58 PM > To: [EMAIL PROTECTED] > Subject: Re: Query in 2 columns? > > > Hi everyone! > > Please see the files attached... > 1.- I would like to do somehtink like the image1.gif > 2.- Using the code below... appears like the image2.gif... > 3.- CODE > ------------------------------------------------------------------------ > ---- > ----- > <CFQUERY datasource="links" NAME="consulta"> > SELECT CAT_NAME, SUBCAT_NAME, > links_categories.CAT_ID, links_subcategories.SUBCAT_ID, > links_subcategories.CAT_ID > FROM links_categories RIGHT JOIN links_subcategories > ON links_categories.CAT_ID = links_subcategories.CAT_ID > </CFQUERY> > > <table width="594" border="1" cellspacing="0" cellpadding="0"> > <cfoutput query="consulta" group="cat_name"> > <cfif consulta.currentrow mod 2> > <tr> > </cfif> > <td><b>#cat_name#</b><br> > <cfoutput>#subcat_name#, </cfoutput> > </td> > </cfoutput> > </tr> > </table> > ------------------------------------------------------------------------ > ---- > ----- > Questions... > a.- Why the category DEPORTE make a break in two? > b.- What do I have to add or change to put this code like the > image1.gif? > > Best regards, > > Javier > > > > ------------------------------------------------------------------------ > - > This email server is running an evaluation copy of the MailShield anti- > spam software. Please contact your email administrator if you have any > questions about this message. MailShield product info: > www.mailshield.com > > ----------------------------------------------- > To post, send email to [EMAIL PROTECTED] > To subscribe / unsubscribe: http://www.dfwcfug.org > > ------------------------------------------------------------------------- > This email server is running an evaluation copy of the MailShield anti- > spam software. Please contact your email administrator if you have any > questions about this message. MailShield product info: www.mailshield.com > > ----------------------------------------------- > To post, send email to [EMAIL PROTECTED] > To subscribe / unsubscribe: http://www.dfwcfug.org > > ------------------------------------------------------------------------- > This email server is running an evaluation copy of the MailShield anti- > spam software. Please contact your email administrator if you have any > questions about this message. MailShield product info: www.mailshield.com > > ----------------------------------------------- > To post, send email to [EMAIL PROTECTED] > To subscribe / unsubscribe: http://www.dfwcfug.org > ------------------------------------------------------------------------- This email server is running an evaluation copy of the MailShield anti- spam software. Please contact your email administrator if you have any questions about this message. MailShield product info: www.mailshield.com ----------------------------------------------- To post, send email to [EMAIL PROTECTED] To subscribe / unsubscribe: http://www.dfwcfug.org
