|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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> |
|
#2
|
|||
|
|||
|
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.
__________________
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 |
|
#3
|
||||
|
||||
|
true, also when you do queries, you should do <cfqueryparam> in your sql SELECT.
|
|
#4
|
|||
|
|||
|
alright.....thanks for the hints, yes your right I do need to spend more time on my SQL.....back to the books!
|
|
#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 |
|
#6
|
|||
|
|||
|
Quote:
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!!!! ![]() |
|
#7
|
|||
|
|||
|
Sorry Kiteless,
I did not read your post properly and therefore not realising that you have already recommended Ben's SQL book. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Trouble displaying database query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|