Jump to content

cfoutput problem


dazz_club

Recommended Posts

Hello,i have created a simple cfquery which is------------------------------------------------<cfquery name="tmax" datasource="xxxxxx">SELECT thermaxRange.productName, thermaxRange.productIMG, thermaxLabelRange.range FROM thermaxRange LEFT JOIN thermaxLabelRangeON thermaxRange.thermaxID = thermaxLabelRange.thermaxID </cfquery>------------------------------------------------and basicly what it does is it pulls data from one table, data such as the products name, product image, etc. And then it pulls more data from another table, this data being specific to each product.when i use the cfoutput tags like this------------------------------------------<cfoutput query="tmax"> <p>#productName#</p><br /> <img src="images/thermaxIMG/#productIMG#" title="" alt="" /><br /> <a href="7" >see products</a><br /> #range# </cfoutput>------------------------------------------it repeats the products from one table which is good. But when it comes to displaying the data from another table, it seems to repeat the same product in accordance to the data in the second table.you can have a look here and see what i mean click mewhat you are looking at is the first product being repeated several times . This product should have ABCD next to it only ,not to have it displayed as it is doing so. example of how it should be displayed3 level <--- Both of these are pulled from the first tableproduct imageABCD <---this is pulled from the second tableand then so on for each of the products.i dont know why its displaying it like that.any help would be nice.cheersDarren

Link to comment
Share on other sites

Try this:

<cfoutput query="tmax" group="productName"><b>#productName#</b><br /><cfoutput><img src="images/thermaxIMG/#productIMG#" title="" alt="" /><br /><a href="7" >see products</a><br />#range#<br /><br /></cfoutput><hr><br /></cfoutput>

I think this is the desired look you are after

Link to comment
Share on other sites

Hi Skemcin,Thanks for replying to my post...I implemented your code, had to remove the "by" from "group" as it caused some syntax error when i view the pagewith your code it now looks like thisis ther a way i could have it displayed like;3 levelproduct IMAGEsee productsABCD-----------------------------------4 levelproduct IMAGEsee products-----------------------------------and so on---------------------------rather than having it repeated 4 times?cheersDarren

Link to comment
Share on other sites

ok, try this:

<cfoutput query="tmax" group="productName"><b>#productName#</b><br /><img src="images/thermaxIMG/#productIMG#" title="" alt="" /><br /><a href="7" >see products</a><br /><cfoutput>#range# </cfoutput><br /><hr><br /></cfoutput>

Because productName and productIMG come from the first (parent) table reference, they would both get put in the first <cfoutput> area. The second table reference (by way of the join) gets put into the second <cfoutput> area.Did that work?Oh, sorry about the "group" vs "groupby" syntax error - I had my SQL hat on for a second - interestingly enough their use is not even close to being the same - I catch myself mixing their logic up sometimes.P.S. So youuuuu guys are the ones behind the new Coors bottle - sweet - and just up the road from me - I work in Elk Grove Village but live in Plainfield. I take it you are in the Glenview office (used to work near there off of Willow Road by the old air force base).

Link to comment
Share on other sites

Hi Skemcin,hahaha , "SQL hat on", i could just imagin it..Thanks for that, worked perfectly. So really my problem was applying logic to laying out the cfoutput tags correctly.lol @ coors...yeah we are...in regards to me...I worked 3 months in the glenview office then relocated to england.Thanks for all your help. :)

Link to comment
Share on other sites

Very nice - glad its working.Yes, it was just a matter of applying the correct logic of your output sequence to match the way your query was structured.I'm always intrigued to somehow become involved (even in the most distant respect) with an organization that has a somewhat invisible role in something people are very familiar with. It brings to mind those BASF commercials - if you happen to know what I mean there.Anyway, interesting to learn of you short tenure in Glenview and relocation to England. Seems safe to assume it was worth it - or at least a hard offer to turn down.Well, have a good evening, I know its a little late there. Let me know if you've got anything else you're working on. I'm sort of the resident ColdFusion guru so feel free to send a PM if you like.Take care.

Link to comment
Share on other sites

Hi Skemcin,Totally agree with you on that...I was never aware of this company but I knew of their products, subconsiously as most of their products went under the radar for me. Only once they pointed out examples, it was "Woaw, you guys make this...and that?" Its interesting, thats one thing.Thanks for your positive reply. :)I think I need more help with my friend logic.On the product page, I want to give the user the ability to view more data by simply using a javascript function, Show/Hide or toggle is how they are name this script.Im choosing this because if i opted to show all the data, the pages would be rather large and kinda of ugly.So what i have done is implemented an existing script for this to happen which you can see hereIf you click on the "click for more info", a red box should appear along with all its data. But i think whats happening is because i have laid out that particular data (in my code) like this;

<cfquery name="tmax" datasource="xxxx">				SELECT thermaxRange.productName, thermaxRange.productIMG, thermaxLabelRange.range, 				thermaxLabelRange.Celcius, thermaxLabelRange.fahrenheit, thermaxLabelRange.id				FROM thermaxRange 				LEFT JOIN thermaxLabelRange				ON thermaxRange.thermaxID = thermaxLabelRange.thermaxID ORDER BY thermaxLabelRange.id ASC			</cfquery>						<cfoutput query="tmax" group="productName">				<b>#productName#</b><br />				<img src="images/thermaxIMG/#productIMG#" title="" alt="" /><br />				<a href="7" >see products</a><br />			<cfoutput>				</cfoutput>			<h3 class="spec">Click here for more info</h3>				<div class="productSpec" style="height:300px;width:300px;background-color:red;">					<table class="lables">						<tr style="text-align:left;">							<td> </td>							<td style="font-weight:bold;">°C</td>							<td style="font-weight:bold;">°F</td>						</tr>						<tr>							<td><span style="font-weight:bold;">#range#</span></td>							<td>#Celcius#</td>							<td>#fahrenheit#</td>						</tr>					</table>				</div>					<br /><hr><br />			</cfoutput>

The #Celcius# and #fahrenheit# tags only seem to be pulling out the first field of information for every product. I would like it too loop through this table displaying all the data for each product, as It had dont before.Any ideas to how this could be achieved?cheersDazzclub

Link to comment
Share on other sites

ahh, I think its just a matter of moving your <cfoutput> and your </cfoutput> tags around a little.I think this is close to what you need:

<cfquery name="tmax" datasource="xxxx">	SELECT	thermaxRange.productName,			thermaxRange.productIMG,			thermaxLabelRange.range,			thermaxLabelRange.Celcius,			thermaxLabelRange.fahrenheit,			thermaxLabelRange.id	FROM	thermaxRange			LEFT JOIN thermaxLabelRange ON thermaxRange.thermaxID = thermaxLabelRange.thermaxID	ORDER BY thermaxLabelRange.id ASC</cfquery><cfoutput query="tmax" group="productName"><b>#productName#</b><br /><img src="images/thermaxIMG/#productIMG#" title="" alt="" /><br /><a href="7" >see products</a><br /><h3 class="spec">Click here for more info</h3><div class="productSpec" style="height:300px;width:300px;background-color:red;"><table class="lables"><tr style="text-align:left;"><td> <br /></td><td style="font-weight:bold;">°C<br /></td><td style="font-weight:bold;">°F<br /></td></tr><cfoutput><tr><td><span style="font-weight:bold;">#range#</span></td><td>#Celcius#</td><td>#fahrenheit#</td></tr></table></cfoutput></div><br /><hr><br /></cfoutput>

Link to comment
Share on other sites

Hello,Your right, the code you gave me was close. When I pasted it into my notepad++ and then viewed the page. It worked how I tended it to work, but all that was wrong was that the table itself looked broken. Everything else worked fine.So I looked at your code and started it from scrath. Building it slowly and testing it.the final code looked like this;----------------------------------<cfoutput query="tmax" group="productName"> <b>#productName#</b><br /> <img src="images/thermaxIMG/#productIMG#" title="" alt="" /><br /> <a href="7" >see products</a><br /> <h3 class="spec">more product info + </h3> <div class="productSpec" > <table class="lables" width="200" border="0"> <tr> <td> </td> <td style="font-weight:bold;">°C</td> <td style="font-weight:bold;">°F</td> <td> </td> </tr> <cfoutput> <tr> <td style="font-weight:bold;">#range#</td> <td>#Celcius#</td> <td>#fahrenheit#</td> <td> </td> </tr> </cfoutput> </table> </div> <br /><hr><br /> </cfoutput> ----------------------------------You can see it in action hereIm going to mention you in my blog (I only blog as i can never settle on a good design for my portfolio) you have been such a great help.Cheers mateDazzclub

Link to comment
Share on other sites

Very nice - I'm glad you were able to use the code and build off of it. I appreciate the kind words and reference. You've got to take a lot of credit too for clearly stating your needs and taking the time to work through it. There are plenty of folk that just want to copy-n-paste solutions - it nice to see you taking the time to not only apply the logic but to really understand it.Its pretty funny to hear you talk about the inability to settle on a design fro your own site - I can relate. Its like once you decide to do something, you almost always hate it by the time you are done coding it.In any respect, thanks again for the kind words. I stalk this area of the forums more than the others, so stop by when anything else pops up.BTW, where do you blog? And on the <a> tag used on the more product info link, you might add onmouseover="this.style.cursor='hand'" so it is more intuitively behaves like a link.

Link to comment
Share on other sites

And on the <a> tag used on the more product info link, you might add onmouseover="this.style.cursor='hand'" so it is more intuitively behaves like a link.
Or just set its CSS cursor attribute to "hand" :)
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...