473,382 Members | 1,635 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Loop through multiple queries

139 100+
Hi,

I'm outputting the results of a query to generate some select boxes. The query runs through a list of skills to generate the boxes. Inside this I`m looping through another query to show a choice of skill levels:

Expand|Select|Wrap|Line Numbers
  1. <cftransaction>
  2. <cfquery datasource="taskbook" name="getSkills">
  3. select        LoginNameFK,
  4.         SkillType,
  5.         SkillLevel
  6. from        tblSkillset
  7. where        LoginNameFK = '#staff#'
  8. </cfquery>
  9.  
  10. <cfquery datasource="taskbook" name="getSkillLevel">
  11. select        SkillLevel
  12. from        tblSkillLevel
  13. </cfquery>
  14.  
  15. <cfquery datasource="taskbook" name="getSkillInfo">
  16. select        Skill,
  17.         SkillInfo,
  18.         ID
  19. from        tblSkillList
  20. order by    Skill
  21. </cfquery>
  22. </cftransaction>
  23.  
  24.  
  25. <cfoutput query="getSkillInfo">
  26.  
  27.  
  28. <table style="width: 99%;">
  29. <tr>
  30. <td style="width: 10%;" rowspan="2"><img src="icons/#Skill#.jpg" style="vertical-align: middle;" /></td>
  31. <td class="titleMinorS" style="width: 75%;">#Skill#</td>
  32. <input type="hidden" name="SType_#ID#" value="#Skill#" />
  33. <td style="width: 15%; padding-right: 6px;" rowspan="2">
  34.  
  35.     
  36. <select name="SLevel_#ID#" class="droplist" size="1">
  37. <option value="No Skill">Select One:</option>
  38. <cfloop query="getSkillLevel">
  39. <option value="#getSkillLevel.SkillLevel#">#getSkillLevel.SkillLevel#</option>
  40. </cfloop>
  41. </select>
  42.  
  43. </td>
  44. </tr>
  45.  
  46. <tr>
  47. <td class="tabletextL" style="width: 75%; padding-bottom: 6px;">#SkillInfo#</td>
  48. </tr>
  49.  
  50. </table>    
  51.  
  52. </cfoutput>    
  53.  
This works fine with new users, but when they want to update their existing skills I'd like the existing skill level to be selecred in the select box. I've tried the following, but it only pulls back the result for the first skill and doesn't loop through the others.

Expand|Select|Wrap|Line Numbers
  1. <select name="SLevel_#ID#" class="droplist" size="1">
  2. <option value="No Skill">Select One:</option>
  3. <cfloop query="getSkillLevel">
  4. <option value="#getSkillLevel.SkillLevel#" <cfif getSkills.Skilllevel EQ SkillLevel>selected</cfif>>#getSkillLevel.SkillLevel#</option>
  5. </cfloop>
  6. </select>
  7.  
Any ideas how I can fix this? I'm assuming that CF doesn't know the value of the users skill level against the particular skill...

Thanks
Neil
Jul 19 '11 #1
1 3698
acoder
16,027 Expert Mod 8TB
You will need the skill level for each skill, so you can either

- make separate queries on each iteration to get the skill level for that particular skill; or

- get all the skills and skill levels and put them in an array/struct, so it's easy to access within the loop.

For the first option, you can use query of queries.

There may be other ways, but these 2 came off the top of my head based on your current code.
Jul 19 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: kaptain kernel | last post by:
i've got a while loop thats iterating through a text file and pumping the contents into a database. the file is quite large (over 150mb). the looping causes my CPU load to race up to 100 per...
2
by: ensnare | last post by:
Hi all, I'm using a database session handler and am looking to loop through data residing in the sessions table to make a 'Users online' array. I've found that using urldecode on the data...
2
by: Ivo | last post by:
Hi, I have an audio file (.mid or .wav or .mp3) in an object element: <object id="snd" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"...
45
by: Trevor Best | last post by:
I did a test once using a looping variable, first dimmed as Integer, then as Long. I found the Integer was quicker at looping. I knew this to be true back in the 16 bit days where the CPU's (80286)...
5
by: masood.iqbal | last post by:
My simplistic mind tells me that having local variables within looping constructs is a bad idea. The reason is that these variables are created during the beginning of an iteration and deleted at...
1
by: Diva | last post by:
Hi, I have a data grid in my application. It has 20 rows and I have set the page size as 5. I have a Submit button on my form and when I click on Submit, I need to loop through the rows in the...
5
by: johnb41 | last post by:
I need to loop through a bunch of textbox controls on my form. The order of the loop is very important. For example, the top one must be read first, then the one below it, etc. My first...
0
by: anthon | last post by:
Hi all - first post! anywho; I need to create a function for speeding up and down a looping clip. imagine a rotating object, triggered by an action, and slowly decreasing in speed, till it...
20
by: Ifoel | last post by:
Hi all, Sorry im beginer in vb. I want making programm looping character or number. Just say i have numbers from 100 to 10000. just sample: Private Sub Timer1_Timer() if check1.value= 1...
2
by: Davaa | last post by:
Dear all, I am a student making a MS Form application in C++. I would ask a question about "Timer". Sample code which I am developing is below. private: System::Void...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.