2 Replies - 1017 Views - Last Post: 06 February 2009 - 01:23 AM Rate Topic: -----

#1 vampirevn01  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 05-February 09

Help me query in Input

Posted 05 February 2009 - 05:30 AM

<cfoutput>
<cfform name="input" ENCTYPE="multipart/form-data">
Data Source:
<cfif isDefined("database")>
<cfinput type="text" name="database" size="25" value="#database#"><br>
<cfelse>
<cfinput type="text" name="database" size="25" value=""><br>
</cfif>
Query: <cfinput type="text" query="SQL" name="query" size="130" value=""><br>
Output: <cfinput type="text" name="output" size="100" value=""><br>
<input type="submit" value="Submit" />
</cfform>
</cfoutput>
<cfif isDefined("database")>
<cfquery name="SQL" DataSource="#database#">
#query#
</cfquery>
<cfoutput>#query#</cfoutput>
<cfoutput query="SQL">
<div>#output#<div>
</cfoutput>
</cfif>


Hello, I have some question for coldfusion.
I want create a page ( for administrator ) can query SQL by tag <cfinput>
Example:
database: testdatasource
query: select * from table_name
output: column_name
We will have query: select * from table_name, and show column_name in this table.

But i have problem, i input output it column_name ( not #column_name#), the tag <cfoutput> will give to me string "column_name", not is query result.
Please help me how to input column_name and this will get column_name of this query, not is string.

Is This A Good Question/Topic? 0
  • +

Replies To: Help me query in Input

#2 sansclue  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 316
  • Joined: 21-November 07

Re: Help me query in Input

Posted 05 February 2009 - 02:38 PM

View Postvampirevn01, on 5 Feb, 2009 - 04:30 AM, said:

But i have problem, i input output it column_name ( not #column_name#), the tag <cfoutput> will give to me string "column_name", not is query result.
Please help me how to input column_name and this will get column_name of this query, not is string.


To use dynamic column names, try using array notation.

#queryName[column_name][row_number]#

The first position is the column name and the second the row number. Since you are using a query loop, you can obtain the row number from the query "currentRow"

<cfoutput query="SQL">
<div>
#SQL["yourColumnNameHere"][currentRow]#
<div>
</cfoutput>


View Postvampirevn01, on 5 Feb, 2009 - 04:30 AM, said:

<cfquery name="SQL" DataSource="#database#">
#query#
</cfquery>


BUT, this is a very dangerous practice. It exposes your database to sql injection, which would allow a malicious to access or modify your database or possibly even drop the database entirely.
Was This Post Helpful? 0
  • +
  • -

#3 vampirevn01  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 05-February 09

Re: Help me query in Input

Posted 06 February 2009 - 01:23 AM

Thanks for help.
I know this is a very dangerous, but i know what i want to do too.
Thanks you again
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1