cfloop

Discussion in 'Programming' started by mofufus, Sep 6, 2005.

  1. #1
    hi guys,

    please excuse my ignorance, but i've been having difficulties with the follow cfloop. here are the codes:

    <cfquery name="GetRef" datasource="#BS#">
    SELECT ref_id, first_name, last_name
    FROM ref
    </cfquery>
    <cfquery name="GetRefOption" datasource="#BS#">
    SELECT assign_ref_id, ar.ref_id, r.first_name, r.last_name
    FROM assign_ref ar join ref r on r.ref_id = ar.ref_id
    WHERE assign_id = #URL.assign_id#
    ORDER BY ar.ref_id
    </cfquery>
    <cfloop query="GetRefOption">
    <tr>
    <cfoutput>
    <td align="right"><b>Referee #GetRefOption.currentrow#:</b></td>
    <td align="left">
    <input type="hidden" value="#assign_ref_id#" name="assign_ref_id">#assign_ref_id#
    <input type="hidden" value="#ref_id#" name="">#ref_id#
    <select name="ref#GetRefOption.currentrow#">
    <option value=""></option>
    <cfloop query="GetRef">
    <option value="#ref_id#" <cfif #GetRefOption.ref_id# eq #ref_id#>selected</cfif>>#first_name# <cfif last_name neq ' '>#last_name#</cfif></option>
    </cfloop>
    </select>
    </cfoutput>
    </td>
    </tr>
    </cfloop>

    in the first cfloop, it was able to grab the data from pass the ref_id separately. but when i used the 2nd cfloop to select if ref_id = ref_id in the table, it only pass 1 ref_id which was the most current one. please help if anyone know if there's an easier when of passing the ref_id to make it select but i also have the hidden form to pass the parameter of other id.

    thank you.
     
    mofufus, Sep 6, 2005 IP
  2. tbarr60

    tbarr60 Notable Member

    Messages:
    3,455
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    210
    #2
    You could alias one of the ref_id's in your query.

    Here's part of the query:

    select ref_id as ref_id_option
     
    tbarr60, Sep 16, 2005 IP