Nested ## variables

Discussion in 'Programming' started by kimimaro, Jan 21, 2009.

  1. #1
    Hi i have come to a complex situation where within my database I have column1 - column50

    So i need display the values of the columns so I query such as

    <cfquery name="get" datasource="blah">

    select *
    from table

    </cfquery>



    Now the problem is with a huge ammount (50) column, I wanted to query out the value from column1 to column50


    im doing

    <cfloop from="1" to="50" index="i">

    #get.column#i##

    </cfloop>


    Problem is i nested ## within another ## which it doesnt works. I tried () also wont work. Please help
     
    kimimaro, Jan 21, 2009 IP
  2. Paul_K

    Paul_K Greenhorn

    Messages:
    85
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    18
    #2
    Do you mean instead of:

    <cfquery name="get" datasource="blah">
    select *
    from table
    </cfquery>
    You want:
    <cfquery name="get" datasource="blah">
    select column1,column2,column3 ect
    from table
    </cfquery>

    But there are 50 colums?
     
    Paul_K, Jan 22, 2009 IP
  3. kimimaro

    kimimaro Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    actually i wanted to do a looping form which captures queries




    <cfquery name="qf">

    select *
    from applicants
    where name in
    (
    <cfqueryparam ...>
    )
    </cfquery>
    </cfquery>



    From above i have a lot of applicant list that will be obtain from the database
    then each needed to be displayed in the form to the user and they may modified the value. Thing is that it displayed repeatly the list of applicants at a time instead one by one and after each value is change one button to confirm the modification to all the applicant.



    The below is partial of my code to display the queries of applicants and the user can change the value in the textfield to modify


    <form ...>

    <cfoutput query="qf">
    <cfparam name="i" default="1">
    <input value=#qf.id# type="hidden" name="id#i#"> *id is my primary key
    <input value="#qf.telephone#" name="telephone#i#">


    <cfset i = i+1>

    </cfoutput>

    <input type="submit" ...>* So only one button exist to modify all

    </form>




    Ok right after that im stuck with this

    <cfoutput query="qm">
    <cfparam name="j" default="1">


    <cfquery...>



    update applicant
    set telephone = '#form.telephone#j##'
    where id = #form.id#j##
    </cfquery>

    <cfset j=j+1>
    ...



    *this is the problem here. i want to loop each form to be unique so each record know what value to be updated with. Sometimes i dont even know if im doing it right or logically. Appreciate if anyone can help else i have to make the system update the files one by one (which is tedious to the client).
     
    kimimaro, Feb 6, 2009 IP
  4. kimimaro

    kimimaro Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Anyone any idea? Im thinking of arrays but i am not good in using them. I just need the update query to successfully loop with each form.telephone and form.id
     
    kimimaro, Feb 7, 2009 IP
  5. Paul_K

    Paul_K Greenhorn

    Messages:
    85
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    18
    #5
    update applicant
    set telephone = '#evaluate("form.telephone#j#")#'
    where id = #evaluate("form.id#j#")#

    Should work for you.
     
    Paul_K, Feb 7, 2009 IP