I've written a script which returns the admin rights of users in a table - their access level, and their priviledges.
The priviledge are returned to a check box and the admin rights to a drop down list. I want this list to have more than one value so that it can be altered.
I've created a loop to run through the drop down options and select the one that matches in the database. However it doesn't appear to be working - its not returning the value in the ViewLevel field. It works on other scripts where I return a single row ID, but not when I return all the rows in the database.
Any ideas what I am doing wrong?
Here's the (stripped down) script:
Expand|Select|Wrap|Line Numbers
- <cfquery datasource="repairmdb" name="GetViewLevel">
- select ViewLevel, ViewText
- from tblViewLevel
- order by ViewLevel
- </cfquery>
- <cfquery name="GetUsers" datasource="repairmdb">
- select distinct LoginName,
- FirstName,
- Surname,
- ViewLevelFK,
- CreateReports,
- CreateUncompReport,
- DeleteRecords,
- AdminRights
- from tblWebsiteUsers
- order by Surname
- </cfquery>
- <div>
- <form action="Devaction_userchange.cfm" method="post">
- <table style="width: 650px;">
- <tr>
- <th class="thl" style="width: 150px">User Name</th>
- <th class="thl" style="width: 100px">Access Level</th>
- <th class="thc" style="width: 100px">Create Report</th>
- <th class="thc" style="width: 140px">Create Uncomp. Jobs Report</th>
- <th class="thc" style="width: 100px">Delete Records</th>
- <th class="thc" style="width: 100px">Admin Rights</th>
- </tr>
- <cfoutput query="GetUsers">
- <tr>
- <td class="thl" style="width: 150px">#FirstName# #Surname#</td>
- <td class="thl" style="width: 100px">
- <select name="ViewLevelFK" size="1" class="droplist">
- <cfloop query = "GetViewLevel">
- <option value="#ViewLevel#"<cfif GetUsers.ViewLevelFK EQ ViewLevel> selected</cfif>>#ViewText#
- </cfloop>
- </select>
- </td>
- <td class="thc" style="width: 100px"><input type="checkbox" name="CreateReports" value="1"<cfif val(CreateReports) NEQ
- 0>checked</cfif>></td>
- <td class="thc" style="width: 140px"><input type="checkbox" name="CreateUncompReports" value="1"<cfif val(CreateUncompReport) NEQ
- 0>checked</cfif>></td>
- <td class="thc" style="width: 100px"><input type="checkbox" name="DeleteRecs" <cfif val(DeleteRecords) NEQ
- 0>checked</cfif>></td>
- <td class="thc" style="width: 100px"><input type="checkbox" name="AdminRights" <cfif val(AdminRights) NEQ
- 0>checked</cfif>></td>
- <td><input type="submit" value="Update" class="buttons" name="updateUsers" /></td>
- </tr>
- </cfoutput>
- </form>
Neil