ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 24th, 2005, 10:17 AM
fergus73 fergus73 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 3 fergus73 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 50 m 8 sec
Reputation Power: 0
Trouble displaying database query

Hello there eh! from Canada,

I am having an issue with displaying some data, well it is being displayed...sort of...
I am a newbie here to the world of Coldfusion, I will try and explain the best I can.

As you can see below I am simply trying to display some data from my database. Most of the text/data is pretty simple, but some of the text/data needs to be queried to another table that holds it's "code" value to display to text that is related to it's code.

Well when the page is displayed the 1st record turns out great!...but after that all the "queried" data within the initial query comes up as the same value as the first record.
I hope I got this across right?....any help/hint/whatever would be great!...
thanks
fergus

ps: I gave a best effort to find this answer....5hrs yesterday, either I cannot use the internet!?, or there is a simple answer!


my code:
<cfquery name="viewall_ads1" datasource="OCHO">
SELECT Zone_LU, PropertyAddress, ContactLastName, ContactFirstName, ContactDayAreaCode,
ContactDayPhoneNumber, ContactDayExtension, ContactEveningAreaCode, ContactEveningPhoneNumber,
ContactEveningExtension, ContactEmail, Rate, RatePeriod_LU, Duration, LeaseTerms_LU,
Internet, DateAvailable, Rooms, Spaces, Heat, Hydro, Water, Cable, AirConditioning,
Laundry, SmokingAllowed, Parking_LU, CostForParking, Furnished_LU, Comment, RatePer_LU
FROM ECWebAds WHERE AccommodationType_LU = 1 ORDER BY Zone_LU, Rate ASC
</cfquery>

<CFOUTPUT QUERY = "viewall_ads1">
<CFSET RCODE = #RATEPERIOD_LU#>
<CFSET RATEPERCODE = #RATEPER_LU#>
<CFSET LCODE = #LEASETERMS_LU#>
<CFSET FCODE = #FURNISHED_LU#>
<CFSET PARKING = #PARKING_LU#>
</CFOUTPUT

><CFQUERY DATASOURCE="OCHO" NAME="GetRatePer">
SELECT * FROM LURatePer WHERE Code = #RATEPERCODE#
</CFQUERY>
<CFOUTPUT QUERY="GetRatePer">
<CFSET RATEPER = '#RATEPER#'>
</CFOUTPUT>

<CFQUERY DATASOURCE="OCHO" NAME="GetRPeriod">
SELECT *
FROM LURatePeriod
WHERE Code = #RCode#
</CFQUERY>
<CFOUTPUT QUERY="GetRPeriod">
<CFSET RPERIOD = '#RATEPERIOD#'>
</CFOUTPUT>

<CFQUERY DATASOURCE="OCHO" NAME="GetFurnished">
SELECT *
FROM LUFurnished
WHERE Code = #fCode#
</CFQUERY>
<CFOUTPUT QUERY="GetFurnished">
<CFSET FURNISHED = '#FURNISHED#'>
</CFOUTPUT>

<CFQUERY DATASOURCE="OCHO" NAME="GetParking">
SELECT *
FROM LUParking
WHERE Code = #Parking#
</CFQUERY>
<CFOUTPUT QUERY = "GetParking">
<CFSET PARKINGSPACE = '#PARKING#'>
</CFOUTPUT>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<cfoutput query="viewall_ads1">
<table width="181%" border="0" cellpadding="7" cellspacing="2">
<tr>
<td>ZONE - #viewall_ads1.Zone_LU#, Date Available:
<CFIF #viewall_ads1.DateAvailable# LTE Now()> Now
<CFELSE>
#DateFormat(viewall_ads1.DateAvailable, "mmmm d, yyyy")#
</CFIF><br>
#dollarformat(viewall_ads1.Rate)# / #RATEPER# / #RPERIOD#<br>
Bedrooms: #viewall_ads1.Rooms# with #viewall_ads1.Spaces# available, with a minimum lease term of #viewall_ads1.Duration#months.<br>
Utls that are included: Heat: #yesnoformat(viewall_ads1.Heat)#, Hydro: #yesnoformat(viewall_ads1.Hydro)#, Water: #yesnoformat(viewall_ads1.Water)#.<br>
It is #FURNISHED# , for parking it has #PARKINGSPACE#.<br>
Laundry: #yesnoformat(viewall_ads1.Laundry)# - A/C:#yesnoformat(viewall_ads1.AirConditioning)# - High Speed Intrnt Avail:#yesnoformat(viewall_ads1.Internet)#<br>
Comments: #viewall_ads1.Comment#<br>
Contact #viewall_ads1.ContactFirstName# #viewall_ads1.ContactLastName# , Days-(#viewall_ads1.ContactDayAreaCode#)#viewall_ads1.ContactDayPhoneNumber# or Nights-(#viewall_ads1.ContactEveningAreaCode#)#viewall_ads1.ContactEveningPhoneNumber#<br> #viewall_ads1.ContactEmail# <br>
</tr>
</table>
</cfoutput>
</body>
</html>

Reply With Quote
  #2  
Old February 24th, 2005, 12:54 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,682 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 15 h 25 m 55 sec
Reputation Power: 53
I know you're a new developer, but it looks to me like you need to learn more about SQL. Whenever you run one query and then use the results of that query to run other queries, a red flag should go up in your mind. In almost all cases, you can do all of this in one query using a table join.

Here is a place to start: http://www.w3schools.com/sql/sql_join.asp

And I highly recommend Ben Forta's Learn SQL in 10 Minutes. It's only $14.99.
Comments on this post
fergus73 disagrees: A good hint.....
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old February 24th, 2005, 01:17 PM
Panther893's Avatar
Panther893 Panther893 is online now
MostarDesigns.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Posts: 834 Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 22 h 29 m 4 sec
Reputation Power: 56
Send a message via MSN to Panther893
true, also when you do queries, you should do <cfqueryparam> in your sql SELECT.
Comments on this post
fergus73 disagrees: people trying to help a newbie is always nice!

Reply With Quote
  #4  
Old February 24th, 2005, 01:29 PM
fergus73 fergus73 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 3 fergus73 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 50 m 8 sec
Reputation Power: 0
alright.....thanks for the hints, yes your right I do need to spend more time on my SQL.....back to the books!

Reply With Quote
  #5  
Old February 24th, 2005, 03:20 PM
hoolahawk hoolahawk is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Australia
Posts: 57 hoolahawk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 29 m 43 sec
Reputation Power: 5
Good SQL Book

If you are looking for a fairly decent SQL book, I would recommend:

SAMS Teach Yourself SQL in 10 Minutes by Ben Forta

I have found it a quick and easy overview of SQL, a good place to start if you are learning SQL and also priced reasonably. The ISBN is 0-672-32567-5.

Has anyone else seen this book, what do you think?

Are there any other good SQL books that you could recommend?

Regards

Reply With Quote
  #6  
Old February 24th, 2005, 04:20 PM
fergus73 fergus73 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 3 fergus73 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 50 m 8 sec
Reputation Power: 0
Talking

Quote:
Originally Posted by kiteless
I know you're a new developer, but it looks to me like you need to learn more about SQL. Whenever you run one query and then use the results of that query to run other queries, a red flag should go up in your mind. In almost all cases, you can do all of this in one query using a table join.

Here is a place to start: http://www.w3schools.com/sql/sql_join.asp

And I highly recommend Ben Forta's Learn SQL in 10 Minutes. It's only $14.99.


I just wanted to thank you!...I got it!.....few hours in actually learning SQL it worked!!!!.....very happy....really appreciate it...always better when you figure it out yourself!!!!

Reply With Quote
  #7  
Old February 24th, 2005, 05:07 PM
hoolahawk hoolahawk is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Australia
Posts: 57 hoolahawk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 29 m 43 sec
Reputation Power: 5
Sorry Kiteless,

I did not read your post properly and therefore not realising that you have already recommended Ben's SQL book.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Trouble displaying database query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT