call from same DB, different fields
The subject may seem confusing, but it is very simple really. I am new to CF and I am trying to utilize the same DB, but call different values based on where the content is on the page. I have found a way for it to work, but it seems clumsy and extraneous at best. This is the way I have found to do it:
<cfquery name="getGame25" datasource="dbtest">
SELECT gameID, gameName, gameDev, gameYear, gameConsole
FROM tblGames
WHERE gameID = 25
</cfquery>
<cfquery name="getGame24" datasource="dbtest">
SELECT gameID, gameName, gameDev, gameYear, gameConsole
FROM tblGames
WHERE gameID = 24
</cfquery>
<cfquery name="getGame23" datasource="dbtest">
SELECT gameID, gameName, gameDev, gameYear, gameConsole
FROM tblGames
WHERE gameID = 23
</cfquery>
......
| <cfoutput query="getGame25"> |
| <div class="showcaseText"><p><h1>#gameID#. #gameName#</h1></p></div> |
| <table> |
| <tr> |
| <td>Developer:</td><td>#gameDev#</td> |
| </tr> |
| <tr> |
| <td>Dev Year:</td><td>#gameYear#</td> |
| </tr> |
| <tr> |
| <td>Console:</td><td>#gameConsole#</td> |
| </tr> |
| </table> |
| </cfoutput> |
| <cfoutput query="getGame24"> | |
| <div class="showcaseText"><p><h1>#gameID#. #gameName#</h1></p></div> | |
| <table> | |
| <tr> | |
| <td>Developer:</td><td>#gameDev#</td> | |
| </tr> | |
| <tr> | |
| <td>Dev Year:</td><td>#gameYear#</td> | |
| </tr> | |
| <tr> | |
| <td>Console:</td><td>#gameConsole#</td> | |
| </tr> | |
| </table> |
...you get the idea..
I am wondering if there is a better way ( a cfloop perhaps) that would cut down on the amount of code and the multiple queries to the DB based on wanting to pull just that specific ID for a specific table. Thanks in advance!
